Hello, I am trying to display in a Dynamic Data app, a custom property added to the partial class of an ADO.NET Entity Framework entity class. For example, where Person is a entity in a ADO.NET Entity Framework model, I would add:
public partial class Person
{
public string FullName { get { return FirstName + " " + LastName; } }
}
However, with Dynamic Data, it uses the internal System.Web.DynamicData.ModelProviders.EFTableProvider for generating its columns collection which only allows properties defined in the entity model to be displayed - as in only the database columns, not custom added ones. Does anyone know any work arounds to this, or is it possible and I am missing something obvious. Seems silly I can't do this. LINQ to SQL with Dynamic Data can do this easy as it uses reflection in its DLinqTableProvider to find all properties in the object, not just those with mappings to database fields. EFTableProvider's enumerator to create its columns for Dynamic Data: foreach (EdmMember member in entityType.get_Members()) // only entity DB mapped fields are returned in the Members property
DLinqTableProvider's enumerator to create its columns for Dynamic Data: IEnumerator<PropertyInfo> enumerator = this.GetOrderedProperties(rowType.get_Type()).GetEnumerator()
where GetOrderedProperties returns a list of properties based on reflection: PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
Anyone have any thoughts on how to do this effectively? I need the many-to-many relationship management that Entity Framework provides - otherwise I would stick with LINQ to SQL. Thanks for any help! Cheers, kris