ColumnAttribute.Expression Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets whether a column is a computed column in a database.

Namespace:   System.Data.Linq.Mapping
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

Public Property Expression As String

Property Value

Type: System.String

Default = empty.

Use this property when you use CreateDatabase to define a column as containing computed values.

For example, if you want to create a column defined in SQL as InventoryVal AS UnitPrice * UnitsInStock, use the following expression string: "UnitPrice * UnitsInStock".

System_CAPS_noteNote

LINQ to SQL does not support computed columns as primary keys.

   <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

.NET Framework
Available since 3.5
Windows Phone Silverlight
Available since 7.1
Return to top
Show: