这工作:为什么EnumerableRowCollection <DataRow> .Select()这样编译?
from x in table.AsEnumerable()
where x.Field<string>("something") == "value"
select x.Field<decimal>("decimalfield");
,但是,这并不:
from x in table.AsEnumerable()
.Where(y=>y.Field<string>("something") == "value")
.Select(y=>y.Field<decimal>("decimalfield"));
我也试过:
from x in table.AsEnumerable()
.Where(y=>y.Field<string>("something") == "value")
.Select(y=>new { name = y.Field<decimal>("decimalfield") });
望着。选择的两个重载()方法,我认为后两者都应该返回EnumerableRowCollection,但显然我错了。我错过了什么?
只需添加到这...你正在过滤'x'的表格,但没有为它选择任何东西......你可以保持相同的语法,只需添加'选择x'最后。 – Edyn 2012-07-31 15:51:53