当我有一个 DataView 操作时
EnumerableRowCollection<DataRow> query
= from order in _table.AsEnumerable()
where order.Field<Int32>("key") > 2 && order.Field<Int32>("key") < 4
select order.Field<Int32>("key")=1000, order.Field<string>("name");
我无法形成上述表达式。
当我尝试
select new {key= 1000,name= order.Field<string>("name") };
我有
Cannot implicitly convert type
'System.Data.EnumerableRowCollection<AnonymousType#1>'
to 'System.Data.EnumerableRowCollection<System.Data.DataRow>'
如何形成正确的查询?我的任务是用 1000 替换密钥并保持名称不变。