Skip to content

Entity Framework PrimaryKeyAttribute [Mapping]

Victor Tomaili edited this page May 3, 2021 · 1 revision

(from the official guide)

[namespace: Serenity.Data.Mapping] - [assembly: Serenity.Data]

Set this for primary key fields in table.

Primary key fields are selected on Key column selection mode in [List](List Request) and [Retrieve](Retrieve Request) request handlers.

public sealed class CustomerRow : Row, IIdRow, INameRow
{
   [PrimaryKey]
   public String CustomerID
   {
      get { return Fields.CustomerID[this]; }
      set { Fields.CustomerID[this] = value; }
   }

See also:

  • [Flags Enumeration - Primay key flag](FieldFlags Enumeration#primarykey-flag-see-primarykeyattribute)
  • [Selection mode](Selection mode)
Clone this wiki locally