Assuming that you understood the concept of having syntax to integrate queries into a language,
you may want to see how this works. When you write the following code:
Customer[] Customers = GetCustomers();
var query =
from c in Customers
where c.Country == "Italy"
select c;
the compiler generates this code:
Customer[] Customers = GetCustomers();
IEnumerable<Customer> query =
Customers
.Where( c => c.Country == "Italy" );
From now on, we will skip the Customers declaration for the sake of brevity. When the query
becomes longer, as you see here:
var query =
from c in Customers
where c.Country == "Italy"
orderby c.Name
select new { c.Name, c.City };
the generated code is longer too:
var query =
Customers
.Where( c => c.Country == "Italy" );
.OrderBy( c => c.Name )
.Select( c => new { c.Name, c.City } );
0 comments:
Post a Comment