views:

43

answers:

1

Hey guys,

Is there anyway to make a dynamic fetch in entity framework 4

If you have some inheritcance where a and b inherit from c

Can you call one linq query to get a list of a, and b using the data set for c?

A: 

Do you mean ...

context.C              // all C's (including all A's and all B's)

context.C.OfType<A>()  // all A's

context.C.OfType<B>()  // all B's
Hightechrider
Yes but can you cast context.C to type A in the first example
Kyle
If you do `context.C.Cast<A>()` you'll get exceptions if any `C` isn't an `A`, e.g. any `B` would cause that. You need to filter using `OfType` to avoid that. If you wanted A's and B's but not any other types that derive from C you could `Concat` the A's and the B's into an `IEnumerable<C>`.
Hightechrider