views:

87

answers:

1

I am new to Linq, though I was thinking of making use of LINQ expressions to query within the collections of my business objects.

We have created a new hierarchical set of models with several properties. Some properties have a List<classx>. Would I be able to change the type to IQueryable<classx>? But then how would I add a new instance of classx to it?

Or should I create an IEnumerable<classx> instead?

Many Thanks for clarification,

+2  A: 

List<classx> already implements IEnumerable<classx> - LINQ to Objects doesn't need to use IQueryable<T>.

Unless you want to write your own querying routines with extra logic in (e.g. to use internal indexes etc) you should probably just use LINQ to Objects as it comes out of the box.

Jon Skeet
Thank you Jon. Thats great news. I will then stick to my Lists and use Linq to Object.
Kave
By the way to be sure I am doing this right, I would do my queries on IEnumerable<x> obj = from ... and return the obj as obj.ToList() to make it match my Property's type, correct?
Kave