Expression Property
Collapse the table of content
Expand the table of content

ColumnAttribute.Expression Property

 

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 string Expression { get; set; }

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",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();
		}
	}
}

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