Skip to content

PrimaryKeyAttribute Class ​

Definition ​

Indicates which property should be used as the primary key when mapping a class to a database table.

  • Namespace: JASE.Database
  • Assembly: JASE.Database.dll

Constructors ​

NameDescription
PrimaryKeyAttribute()Initializes a new instance of the PrimaryKeyAttribute class. Use this form when applying the attribute directly to a property.
PrimaryKeyAttribute(string propertyName, string primaryKeyName)Initializes a new instance of the PrimaryKeyAttribute class and specifies the name of the primary key property. Use this form when applying the attribute to a class.

Properties ​

NameDescription
KeyNameGets the name primary key, when not provided it is derived
PropertyNameGets the name of the property to treat as the primary key, when the attribute is applied to a class.

Remarks ​

This attribute can be applied to either a class or a property:

  • When applied to a property, that property is treated as the primary key.
  • When applied to a class, you must specify the name of the primary key property via PropertyName. Only one form of declaration is allowed per type.