views:

21

answers:

0

I have a simple inheritance in my model. The class of an entity is defined by a field (RecordType: int). Now I would like to create a SQL to Entities query where I need to filter only one inherited class. When I use

ctx.CreateQuery<InheritedEntity>() 

it fetches all the classes, rather than only InheritedEntity class.

I tried referring to the inherited class in the SQL:

"SELECT Value p FROM InheritedEntity as p"

But it doesn't work.

I tried adding

"... WHERE RecordType = ..."

But it doesn't work.

I couldn't find anything in MSDN either.

So how do I do that?

EDIT:

Eventually this code worked out for me:

 ctx.CreateQuery<BaseEntity>(sqlText).OfType<InheritedEntity>()

Now I'm wondering if this is the best way to do it.