UniqueAttribute [Mapping]

Estrusco edited this page May 2, 2016 · 1 revision
Clone this wiki locally

(from the official guide)

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

When a field has this flag, its value is checked against existing values in database to be unique.

You can turn on this flag with Unique attribute and determine if this constraint should be checked on service leve (before the check in database level to avoid cryptic constraint errors).

public sealed class UserRow : LoggingRow, IIdRow, INameRow, IIsActiveRow
{
   [Unique]
   public String Username
   {
      get { return Fields.Username[this]; }
      set { Fields.Username[this] = value; }
   }

See also: