ColumnAttribute.Expression プロパティ

定義

列がデータベース内の計算列であるかどうかを示す値を取得または設定します。

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

プロパティ値

既定値は empty です。

[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

注釈

このプロパティは、 を使用して計算値を含む列を定義する場合に使用 CreateDatabase します。

たとえば、 として InventoryVal AS UnitPrice * UnitsInStockSQL で定義された列を作成する場合は、次の式文字列を使用します。 "UnitPrice * UnitsInStock"

Note

LINQ to SQL では、計算列は主キーとしてサポートされません。

適用対象