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

속성 값

기본값 = 비어 있습니다.

예제

[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 .

예를 들어 SQL InventoryVal AS UnitPrice * UnitsInStock에 정의된 열을 만들려면 다음 문자열 "UnitPrice * UnitsInStock"을 사용합니다.

메모

LINQ to SQL은 계산 열을 기본 키로 지원하지 않습니다.

적용 대상