tags:

views:

24

answers:

2

Do linq2sql expressions always return iquerable? Can I return ILIST if I wanted?

+1  A: 

I think this is the way to do it:

IList<SomeType> result = _someCollection.Where(...).ToList();
Jason Miesionczek
A: 

By returning an IList, you are evaluating the query. The beauty of Linq2Sql is that it translates your expression into a sql query and executes that against the server. By returning an IList, you lose this functionality.

There is nothing stopping you from calling .ToList() on your IQueryable object once you have created your query though.

Hope that helps

LorenVS