Share via


ColumnAttribute.Expression Propiedad

Definición

Obtiene o establece un valor que indica si una columna es una columna calculada en una base de datos.

public:
 property System::String ^ Expression { System::String ^ get(); void set(System::String ^ value); };
public string Expression { get; set; }
member this.Expression : string with get, set
Public Property Expression As String

Valor de propiedad

El valor predeterminado es Empty.

Ejemplos

[Column(Storage="_UnitPrice", DbType="Money",Expression="UnitPrice + 1.00")]
public System.Nullable<decimal> UnitPrice
{
    get
    {
        return this._UnitPrice;
    }
    set
    {
        if ((this._UnitPrice != value))
        {
            this.OnUnitPriceChanging(value);
            this.SendPropertyChanging();
            this._UnitPrice = value;
            this.SendPropertyChanged("UnitPrice");
            this.OnUnitPriceChanged();
        }
    }
}
   <Column(Storage:="_UnitPrice", DbType:="Money NOT NULL", Expression:="UnitPrice + 1.00")> _
Public Property UnitPrice() As Decimal
       Get
           Return Me._UnitPrice
       End Get
       Set(ByVal value As Decimal)
           If ((Me._UnitPrice = Value) _
              = False) Then
               Me.OnUnitPriceChanging(Value)
               Me.SendPropertyChanging()
               Me._UnitPrice = Value
               Me.SendPropertyChanged("UnitPrice")
               Me.OnUnitPriceChanged()
           End If
       End Set
   End Property

Comentarios

Utilice esta propiedad cuando use CreateDatabase para definir una columna como que contenga valores calculados.

Por ejemplo, si desea crear una columna definida en SQL como InventoryVal AS UnitPrice * UnitsInStock, use la cadena de expresión siguiente: "UnitPrice * UnitsInStock".

Nota

LINQ to SQL no admite las columnas calculadas como claves principales.

Se aplica a