The error is shown at select when i write next LINQ query:
DataTable dtbl = //...
int count = (from p in dtbl select p.RecordID).Max();
please help me out.
The error is shown at select when i write next LINQ query:
DataTable dtbl = //...
int count = (from p in dtbl 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
.
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.