Here is the original source:
Simple generalization of LINQ
LINQ is the abbreviation for language-integrated query, a newly added language feature in C # 3.0 and VB 9.0 that enables collection-based operations using the built-in query language during programming.
List<user> userlist = Getuserlist () var userwithoddid = from u in userlist where u.userid% 2 = = 1 select U; foreach (User u in userwithoddid) { Console.WriteLine (u.username);}
If you do not have LINQ, to filter out a user object with an odd ID, you need to create a list and then traverse the entire list to put a user object that meets certain criteria into a new list. With LINQ, this part of the filter becomes very easy, even if you need a word to do it. If this example is not enough to show that LINQ contributes significantly to productivity, follow my next article (tentatively titled Why We Embrace LINQ). LINQ specifically refers to the use of From...where...select in the above code, whose return value is iqueryable<t> or ienumerable<t>.
LINQ to SQL is a lightweight O/R mapping solution built into. NET 3.5 that maps data tables to entity objects, allowing developers to manipulate the database. As you can see, LINQ to SQL is only an implementation of LINQ and provides a LINQ Provider that queries the SQL Server database.
LINQ Provider is the executor of a LINQ query, and the standard LINQ syntax supports many operators, but a specific LINQ implementation might support only a subset of them. The. NET 3.5 Default provides three LINQ Provider, namely LINQ to Object (the above example), LINQ to SQL, and LINQ to XML.
LINQ to XXX represents a solution that uses LINQ to query for data such as XXX. We can customize the LINQ Provider to work with specific datasets using our custom query rules. Dozens of types of LINQ Provider, such as LINQ to Flickr,linq to NHibernate, are now available on the Internet and are already in the Beta 3 phase of the ADO Framework, and will eventually provide a LINQ Provider, called "LINQ to Entities".
--------------------------------------------------------------------------------------------------------------- ---------------------------------------
Using LINQ can improve the operational efficiency of a collection, facilitate the search for a single record in a particular collection, avoid using a foreach loop, frequent database queries, and can be used appropriately based on the actual development case.
When we need to loop through every piece of data in a collection in development, we can put the corresponding data in a single list in memory, and then use LINQ to get individual records for business processing. This is much more efficient than using FROEACH traversal or single queries from a database
Reference read: LINQ topics
Http://www.cnblogs.com/lyj/archive/2008/01/20/1046196.html
Querying a collection for specific objects with LINQ