-
Notifications
You must be signed in to change notification settings - Fork 804
Entity Framework SetFieldFlagsAttribute [Mapping]
Victor Tomaili edited this page May 3, 2021
·
1 revision
(from the official guide)
[namespace: Serenity.Data.Mapping] - [assembly: Serenity.Data]
public SetFieldFlagsAttribute(FieldFlags add, FieldFlags remove = FieldFlags.Internal);
This attribute can be used on fields to include or exclude a set of flags. It takes a first required parameter to include flags, and a second optional parameter to exclude flags.
To turn on TrimToEmpty flag on a field, we use it like this:
[SetFieldFlags(FieldFlags.TrimToEmpty)]
public string MyField
{
get { return Fields.MyField[this];
set { Fields.MyField[this] = value;
}
To turn off Trim flag:
[SetFieldFlags(FieldFlags.None, FieldFlags.TrimToEmpty)]
public string MyField
{
get { return Fields.MyField[this];
set { Fields.MyField[this] = value;
}
To include TrimToEmpty and Updatable but remove Insertable:
[SetFieldFlags(FieldFlags.Updatable | FieldFlags.TrimToEmpty, FieldFlags.Insertable)]
public string MyField
{
get { return Fields.MyField[this];
set { Fields.MyField[this] = value;
}
Insertable and Updatable attributes are subclasses of SetFieldFlags attribute.
See also: [FieldFlags Enumeration](FieldFlags Enumeration)
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions