How to retrieve base class only (entity framework)?

Posted by Juvaly on Stack Overflow See other posts from Stack Overflow or by Juvaly
Published on 2010-03-13T06:53:18Z Indexed on 2010/03/13 7:05 UTC
Read the original article Hit count: 153

Filed under:

Hi All,

I've been scratching my head here for a while now... I have a Consumer class and a BillableConsumer class that inherits Consumer. They are both a part of the Consumers set. The problem is that this following query:

Consumer consumer = (from c in _ctx.Consumers where c.ID = id select c).First();

returns a BillableConsumer instance! Just the same as this query:

BillableConsumer bconsumer = (from c in _ctx.Consumers.OfType<BillableConsumer>() where c.ID = id select c).First();

How can I return an instance of just the base class? (these are separate tables in the data store).

© Stack Overflow or respective owner

Related posts about entity-framework