New Posts New Posts RSS Feed: DB First Metadata for custom property
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DB First Metadata for custom property

 Post Reply Post Reply
Author
pglaspey View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Feb-2008
Location: United States
Posts: 2
Post Options Post Options   Quote pglaspey Quote  Post ReplyReply Direct Link To This Post Topic: DB First Metadata for custom property
    Posted: 10-Dec-2012 at 10:54am
How do I get metadata generated for a custom property that only exists in the partial class file.

If I attribute it directly or add it to the helper class it does not work.

Is this possible?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 10-Dec-2012 at 3:53pm
You can add a DataEntityProperty for these "non-native" properties.
 
It looks like we don't have this documented, but you can "extend" the PropertyMetadata partial class for the entity to add the static DataEntityProperty field.  Something like this:
 
public partial class Customer {
  public string ACustomProp { get; set; }
 
  public partial class PropertyMetadata {

    public static readonly DataEntityProperty<Customer, string> ACustomProp  =
       new DataEntityProperty<Customer, string>(propertyName: "ACustomProp",
                                      isNullable: false,
                                      isPartOfKey: false,
                                      concurrencyStrategy: ConcurrencyStrategy.None,
                                      isAutoIncrementing: false,
                                      relatedNavigationPropertyName: null,
                                      isNativeProperty: false);
  }
}
 
DevForce will discover the property definitions when the model is accessed.  You can then obtain property metadata from the EntityMetdataStore.
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down