MS EntityFramework: how to split entity with inheritance?
I have table name Transaction in the DB. I want to have 2 subclasses TransactionA and TransactionB. I've made it as described here: http://www.robbagby.com/entity-framework/entity-framework-modeling-table-per-hierarchy-inheritance/comment-page-1/#comment-607
As I use T4 templates I've generated self-tracking entities.
Everything is okay but one thing. I can see generated entities TransactionA and TransactionB but I cannot see them in the context object (Objec开发者_如何学CtContext). Is it normal? If so, how could I get TransactionB from the table using context if only Transaction class is accessible?
Thanks
This is as expected. Transaction A en B derive from the baseclass Transaction. In your entity model you can access them through the collection of Transactions like this:
Context context = new Context();
List<TransactionB> list = context.Transactions.OfType<TransactionB>().ToList();
精彩评论