Print Page | Close Window

Defining Base Type for each Entity

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2000
Printed Date: 21-Apr-2026 at 11:38pm


Topic: Defining Base Type for each Entity
Posted By: midnit
Subject: Defining Base Type for each Entity
Date Posted: 23-Jul-2010 at 12:42pm

So in our continued effort to upgrade to 2010...we have different base types for certain entities but I have yet to see a way to accomplish the same thing with the 2010 version.

Perviously the XML attribute ib:AdornedBaseTypeName="BasePricingEntity -> Entity" let use do this. Is there no way to accomplish the same thing now?



Replies:
Posted By: ting
Date Posted: 23-Jul-2010 at 2:47pm
In DevForce 2010, you can only have a single injected base class.  If you don't know already, you set this using the "Injected Base Type" field on the property sheeet for the edmx.


Posted By: midnit
Date Posted: 26-Jul-2010 at 5:32am
Yes, but as I said I need more the one.
 
So...what ARE the options? Is it possible to change the t4 template such to read a userdefined xml attribute in the model to override the base type? No hidden attributes for the users control their own destiny?
 
When will the product include the feature to define our own base types per entity?


Posted By: ting
Date Posted: 26-Jul-2010 at 8:28pm
Sorry, I didn't have time earlier to elaborate.
 
This is actually a restriction of the Entity Framework.  This worked in DevForce 2009 because we had full control over the object hierarchy.  In DevForce 2010, the Entity Framework creates the DevForce objects directly (which results in better performance among other things), but we have to live with this constraint.
 
An alternative implementation is to define extension methods on interfaces and the mark the entities with the desired interface.  This gives the same API feeling for the business object consumers, and the underlying implementation can still be quite clean.
 
For those unfamiliar with extension methods, here's the MSDN link:
http://msdn.microsoft.com/en-us/library/bb383977.aspx - http://msdn.microsoft.com/en-us/library/bb383977.aspx
 



Print Page | Close Window