Condividi tramite


ColumnAttribute.IsPrimaryKey Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets whether this class member represents a column that is part or all of the primary key of the table.

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

Syntax

'Declaration
Public Property IsPrimaryKey As Boolean
public bool IsPrimaryKey { get; set; }

Property Value

Type: System.Boolean
Default = false.

Remarks

Assuming an entity class, you must provide at least one member with this attribute, and it must be mapped to the primary key or a unique key in the corresponding table or view. Failure to do this prompts LINQ to SQL to consider instances of the class as read-only for submitting changes to the database.

If you designate more than one member of the class by using this property, the key is said to be a composite of the associated columns.

NoteNote:

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

Version Information

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.