ColumnAttribute.Expression Propriedade
Definição
Obtém ou define se uma coluna é uma coluna computada em um banco de dados.Gets or sets whether a column is a computed column in a database.
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 da propriedade
Padrão = vazio.Default = empty.
Exemplos
[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
Comentários
Use essa propriedade quando você usar CreateDatabase para definir uma coluna como contendo valores computados.Use this property when you use CreateDatabase to define a column as containing computed values.
Por exemplo, se você quiser criar uma coluna definida no SQL como InventoryVal AS UnitPrice * UnitsInStock , use a seguinte cadeia de caracteres de expressão : "UnitPrice * UnitsInStock" .For example, if you want to create a column defined in SQL as InventoryVal AS UnitPrice * UnitsInStock, use the following expression string: "UnitPrice * UnitsInStock".
Observação
LINQ to SQL não oferece suporte a colunas computadas como chaves primárias.LINQ to SQL does not support computed columns as primary keys.