ColumnAttribute.Expression Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define se uma coluna é uma coluna calculada numa base de dados.
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 Propriedade
Padrão = vazio.
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
Observações
Use esta propriedade ao CreateDatabase definir uma coluna como contendo valores calculados.
Por exemplo, se quiser criar uma coluna definida em SQL como InventoryVal AS UnitPrice * UnitsInStock, use a seguinte cadeia de expressões : "UnitPrice * UnitsInStock".
Note
LINQ para SQL não suporta colunas computadas como chaves primárias.