开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜