What are the requirements for an object (or collection) to be linq compatible?
So for my experience with linq has been with the List<T> collection, but what is the actual requirement? Is it any collection? Any object that inherts from ___?
blah blah blah is here! blah blah » Close
What are the requirements for an object (or collection) to be linq compatible?
So for my experience with linq has been with the List<T> collection, but what is the actual requirement? Is it any collection? Any object that inherts from ___?
Got feedack? Found a bug? report it here.
2 answers
there's no hierarchy requirements, it operates on a number of different underlying structures. It's usually anything enumerable. you can use it with linq to sql and entity framework. though conceptually it looks the same, it builds dynamic SQL and passes that into the db instead of operating on a full data set.
answered 2 years ago by:
2309
I've used Linq on XML documents and SQL tables. Linq for SQL is, in my opinion, spectacular. No more creating a pile of objects and then building a string for your SQL command. You can think of Linq as basically like an in-line scripting system for querying data. Looking through one of my programs, I even used Linq on an array...
answered 2 years ago by:
84
84
I actually found another use! It may not be the best use, but it worked. I had a short property that I was setting to the value of a short?. Obviously without an explicit cast, this causes problems....or.... you just add from Linq.... shortValue = nullableShortValue.FirstOrDefault(0);