BobRosas
asked on
Largest value of a field (type int) in C#
I have a field (RcdId) which is of Int type. I would like to extract the value of the largest one in the table. In this example I want the result of 236. I posted code using Max and Asc but they do not work in C#. Your help is appreciated.
Emp No RcdId
101 235
102 236
103 222
104 24
105 91
My environment is Visual Studio, the language is C# and I'm attached to a SQL Server db.
Emp No RcdId
101 235
102 236
103 222
104 24
105 91
My environment is Visual Studio, the language is C# and I'm attached to a SQL Server db.
var LastRcdId = (from c in dbTimeClockPlus.EmployeeLists where Max(c.RecordId)ASC select c.RecordId).FirstOrDefault();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
pretty much a repeat of kaufmed's solution.
//using System.Linq;
int LastRcdId = dbTimClockPlus.EmployeList .Max(rec => rec.RecordId);
//using System.Linq;
int LastRcdId = dbTimClockPlus.EmployeList
ASKER
Thank you both for your quick response. Kaufmed was 1st and it worked like a charm! So I awarded him points but I think all you EE guys are great! Thanks again!
NP. Glad to help. = )
ya, didn't expect points just offering another way to do the same thing.
glad you got your answer.
glad you got your answer.
Open in new window