Why doesn't EnumerableRowCollection<DataRow>.Select() compile like this?
Posted
by David Fox
on Stack Overflow
See other posts from Stack Overflow
or by David Fox
Published on 2010-04-01T13:48:17Z
Indexed on
2010/04/01
13:53 UTC
Read the original article
Hit count: 767
This works:
from x in table.AsEnumerable()
where x.Field<string>("something") == "value"
select x.Field<decimal>("decimalfield");
but, this does not:
from x in table.AsEnumerable()
.Where(y=>y.Field<string>("something") == "value")
.Select(y=>y.Field<decimal>("decimalfield"));
I also tried:
from x in table.AsEnumerable()
.Where(y=>y.Field<string>("something") == "value")
.Select(y=>new { name = y.Field<decimal>("decimalfield") });
Looking at the two overloads of the .Select() method, I thought the latter two should both return EnumerableRowCollection, but apparently I am wrong. What am I missing?
© Stack Overflow or respective owner