I have a ‘var’ that contains results from two tables using LINQ to SQL. I need to get MAX(table1.ID). But I can’t do:
myVar.table1.ID.Max()
since myVar has no idea about the objects it is holding. What should that syntax look like?
EDIT:
The full query is:
var myVar = from table1 in db.table1s
join table2 in db.table2s
on table1.empid equals table2.empid
where table2.deptid = deptid
select table1
Several results are returned. I want the max table1.ID row.
Okay, it looks like you want:
Or if you may not have any entries:
Then
maxIdwill benullif it’s empty.