Mr. Arnold said:
I don't know what you're talking about. And I don't think you know what
you're talking about.
huh - other than the 'var =' typo - what's the problem ?
sure I use it all the time
(var =) I don't think that's going to work anywhere but giving a compile
error.
if we are going to get typographically picky here - did you try to compile
the original example you gave ? Even the new one added below here won't
compile as is.
var thelist = (from a in list.where(a => a.age == 40)select a)tolist();
var list = (from a in accounts1.OrderBy(b => b.Lastname).Where(c => c.Age
== 40)).tolist();
Do you not see the power of the expression?
Sure I do - I also see the unnecessary complexity, jumble and
innefficiency - do you ?
Personally I try not to mix linq query syntax with & lambda expressions
whenever possible - KISS.
In your original example : ( note the corrections - the original code would
not compile ! )
var thelist = (from a in list.Where(a => a.age == 40)select a).ToList();
the segment
(from a in list.Where(a => a.age == 40)select a
is functionally equivalent to both
from a in list where a.age == 40 select a
and
list.Where(a => a.age == 40)
Depending on the usage .Tolist() could be unnecessary, if for some reason
you really need it then
list.Where(a => a.age == 40).ToList()
will do it, by responding that either
var thelist = list.Where(a => a.age == 40);
or
var thelist = from a list where age == 40 select a;
are both simpler ( less convoluted ) than
var thelist = (from a in list.Where(a => a.age == 40)select a)ToList();
is just stating the obvious
similarly with the 2nd newly added example , either
var list = from a in accounts1 where a.Age == 40 orderby a.Lastname
select a;
or
var list = accounts1.Where(a => a.Age == 40).OrderBy(a => a.Lastname);
are both perferable to
var list = (from a in accounts1.OrderBy(b => b.Lastname).Where(c =>
c.Age == 40)).tolist();
both in readablilty and efficiency.
You should have been posting to the OP and not me.
I was replying to the thread, not to you.
The next time you get in someone's face with a bunch of nonsense you had
better be correct yourself.
in whose face how and with what nonsense ?
as noted above - your examples were/are incorrect as well.
just out of curiosity - why did you change your original link from
http://en.wikipedia.org/wiki/Language_Integrated_Query to
http://msdn.microsoft.com/en-us/library/bb397687.aspx
and add the second linq example as if it was part of your original response
?