In all of the previous examples we have shown ‘Named” attributes specified with the form “EntityPropertyNames.{PropertyName}. This is a recommended pattern that ensures type safety. However, the following two attribute specifications have exactly the same effect:
C# | [BeforeSet(EntityPropertyNames.FirstName)] // or [BeforeSet("FirstName")] |
VB | <BeforeSet(EntityPropertyNames.FirstName)> ' or <BeforeSet("FirstName")> |
The EntityPropertyNames reference is to a class that is generated (as multiple partial classes) inside the designer code file associated with the entity model. Its primary purpose is to allow specification of property names as constants.
Here we see the EntityPropertyNames generated for a Customer entity class:
C# | public new partial class EntityPropertyNames : IbEm.Entity.EntityPropertyNames { public const String CustomerID = "CustomerID"; public const String CustomerID_OLD = "CustomerID_OLD"; public const String CompanyName = "CompanyName"; public const String ContactName = "ContactName"; public const String ContactTitle = "ContactTitle"; public const String Address = "Address"; public const String City = "City"; public const String Region = "Region"; public const String PostalCode = "PostalCode"; public const String Country = "Country"; public const String Phone = "Phone"; public const String Fax = "Fax"; public const String RowVersion = "RowVersion"; public const String Orders = "Orders"; } |