Up Property interceptors
DevForce Resource Center » Development guide » Model » Property interceptors » The EntityPropertyNames class

The EntityPropertyNames class

Last modified on September 14, 2012 19:15

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";
}



Note that because EntityPropertyNames is generated as a partial classe, you can add your own property names to the class for any custom properties that you create.

Created by DevForce on October 07, 2010 13:28

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade