Comparison : LINQ vs LAMBDA Expression [closed]
I guess you mean query expression
when talking about LINQ here.
They are equivalent. The compiler changes the query expression
into the equivalent Lambda expression before compiling it, so the generated IL is exactly the same.
Example
var result = select s from intarray
where s < 5
select s + 1;
is exactly the same as
var result = intarray.Where( s => s < 5).Select( s => s+1);
Note that if you write the query expression like this:
var result = select s from intarray
where s < 5
select s;
It's converted to:
var result = intarray.Where( s => s < 5);
The final call to Select is omitted because it's redundant.
a quick comparison in reflector would probably do the trick. However, from a 'preference' standpoint, I find lambda statements easier to follow and write and use them across the board whether it be with objects, xml or whatever.
If performance is negligible, i'd go with the one that works best for you.
i actually started off a little topic looking at linq methods which may be of interest:
What's your favourite linq method or 'trick'
cheers..