MSDN Archive Home
Help and FAQs
Persistence Ignorance (POCO) Adapter for Entity Framework
All Resource Updates
Create New Discussion
Referencing inherited entities
May 13 2009 at 11:19 AM
While attempting to save class that is inherited from another class the following issue was uncovered...
The POCO adapter seems to have issues when one entity has a navigation property to another which is inherited from a third entity. For example, our SuperVisorDetails entity had a reference to Individual. Individual is a typeof Party.
This caused the POCO adapter generated code to have 2 build errors, both relating to the same call to the following method:
The error was saying that the Method GetPocoEntityOrNull was not on the IndidualAdapter. This method is added as an extension method on Types of IPocoAdapter<T> of which the IndividualAdapter is.
The fix/interim hack is:
The 2 lines that fail (as above) need to be changed to:
PocoEntity.Supervisor = (Individual)(this.Supervisor as PartyAdapter).GetPocoEntityOrNull();
The extension method is still available on the PartyAdapter – so we cast to one of those and call the method.
We then cast from the Party to an Individual as the PocoEntity.Supervisor is expecting one of those.
The questions are:
1. Why the extension method is not present on the IndividualAdapter but IS on the PartyAdapter
2. Maybe alter the POCOAdapter code generator to use the fixed line as above – this could be interesting though….
Sign in to post message or set email notifications
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.