Professional Documents
Culture Documents
IEnumerable<string> firstNames =
from people in list orderby
people.FirstName select
people.FirstName;
// == {”Golan”, “Oz”}
Compiler Conversion =
list.OrderBy(people =>
people.FirstName).Select(people =>
An example for creating new
anonymous type object with LINQ
Multiple generators:
from c in customers
where c.City == "London"
from o in c.Orders
where o.OrderDate.Year == 2005
select new { c.Name, o.OrderID,
o.Total }
//= {{“Oz”,123456,7},
{“Golan”,78910,8}}
Expression Tree is the feature which
enables you to write function which can
be complied on-demand basis.
It stores the function in form of
structured data rather than executable
code
Expression<Func<int, int>> e = x =>
x * 5;
And if you want to invoke the above
exp you need to compile it first:
var f = e.Compile();
And execute:
Expression<Func<int, bool>> exprTree = num => num <
5;