In contrast to databases I approve using Linq to entities or collections.
It is a very useful addition to the .NET platform and once you are familiar to it you can't stop using it.
The most common usage, in my opinion, is to filter collections in a very elegant and bug-free way. Why write methods that iterate or use delegates that we must write when Linq does it all?
In the example below we take a list of Customer and do a "groyp by" City, then we take the first occurrence in each group:
List< Customer > customers = GetCustomers();
var query = (from cust in customers group cust by cust.City into g select new { FirstTypeInGroup = g.First() });
foreach (var item in query)
{
//
}
Cien años de una oportunidad (perdida)*
5 weeks ago

No comments:
Post a Comment