Considering the following architecture:
- a base object ‘Entity’
- a derived object ‘Entry:Base’
- and a further derived object ‘CancelledEntry:Entry’
In EntitySQL I can write the following:
[...] where it is of (only MyEntities.Entry) [...]
to return only objects of type Entry and no Entity or CancelledEntry.
In linq to sql, the following command will return objects of type Entry and CancelledEntry.
EntityContext.EntitySet.OfType<Entry>()
What is the syntax/function to use to return only objects of type Entry?
Why don’t you apply an extension method on IQueryable< Entry > called ApplyBaseEntryFilter() which would apply this filter and return an IQueryable< Entry >.
This is an example of how to reuse linq query fragments. Using extension methods on IQueryable< Entity > is a great way to re-use queries as you should neve rneed to copy and paste query fragments around your application, hope that helps.