Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

linq

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.

like image 719
hari Avatar asked Nov 02 '10 12:11

hari


1 Answers

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

like image 165
Daniel A. White Avatar answered Oct 28 '22 12:10

Daniel A. White