Recently, using the entity Framework to do a small example of MVC, found that the Code with LINQ syntax is still a lot of, decided to study LINQ, to fill in the. NET technology, is not everyone is familiar with these technologies, because the project is simple, not how to use.
Reference book LINQ in Action the English version of the comparison, also do not know this is not the best introduction of LINQ books, see the online evaluation is still possible. You can download it at the Peel House. If there is a better book recommendation, please leave a message to me
The first chapter: a Brief introduction to LINQ, or start with writing code.
One: Hello LINQ World: This example is too simple to see the benefits of LINQ, so keep looking at the second example.
//linq Code
string[] words = {"Hello", "Wonderful", "LINQ", "Beautiful", "World"};
var hellolinq = from worldlinq in words
where Worldlinq. Length <= 5
Select Worldlinq;
foreach (var h in hellolinq)
{
Console.Write (h);
}
// old general code
foreach (String hl in words)
{
if (hl. Length <= 5)
{
Console.Write (HL);
}
}
Console.readkey ();
Two: Hello Linq World Order and group
Three:
The LinQ in Action learns the first chapter example.