Читати англійською Редагувати

Поділитися через


MetaDataMember.IsPrimaryKey Property

Definition

When overridden in a derived class, gets a value that indicates whether this member is part of the type's identity.

C#
public abstract bool IsPrimaryKey { get; }

Property Value

true if this member is part of the type's identity; otherwise, false.

Remarks

If this property is true, the class member represents a column that is part of the table's unique key. More than one member of the class can have this property set to true for a key that is a composite of the associated columns. For an entity class, at least one member must have this attribute and should be mapped to the primary key or a unique key in the corresponding table or view. Otherwise, LINQ to SQL considers instances of the class as read-only for the purpose of submitting changes to the database.

The set of columns identified with IsPrimaryKey are not required to be the primary key. They simply denote a set that uniquely identifies the entity. Common alternatives include clustering index columns or other unique key columns.

Applies to

Продукт Версії
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1