views:

33

answers:

1

If you return IList(T) from your repository ...

How could you efficiently create SQL queries when you join the data together?

Is it REQUIRED to expose IQueryable / IEnumerable data structures for those methods? This to me is bad.

Or

Am I missing some basic concept?

Right now I have a repository methods like:

IList<T> Get( Expression(...) filter, Expression(...) sort, int skip, int take)

where null indicates Get All. This works very well until I want to find all Orders of a set of Customers without doing a query for each customer.

+1  A: 

It's not required to expose IQueryable<T>, but if you don't then you run into exactly the problem you're describing: You can't further compose the queries.

One solution is to put an entity service layer in front of the repository. The service layer is EF-ignorant, but can do LINQ projections. Projecting in LINQ results in a composed, single DB query.

I have a demo here.

Craig Stuntz