开发者

Cannot convert lambda expression to type 'string' because it is not a delegate type

开发者 https://www.devze.com 2023-01-23 17:17 出处:网络
The error is shown at select when i write next LINQ query: DataTable dtbl = //... int count = (from p in dtbl开发者_C百科 select p.RecordID).Max();

The error is shown at select when i write next LINQ query:

DataTable dtbl = //...
int count = (from p in dtbl开发者_C百科 select p.RecordID).Max();

please help me out.


Try this.

int count = dtbl.Max(p => p.RecordID);

Edit:

You can't easily use Linq on a DataTable.

See: LINQ query on a DataTable


According to your comment that dtbl is a DataTable you can do:

int count = dtbl.AsEnumerable().Max(r => r.Field<int>("RecordID"));

You will need to add a reference to System.Data.DataSetExtensions.dll and add a using System.Data directive to the source file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号