none
find maxvalue from a table in LINQ RRS feed

  • Question

  • i have a table called Student_master and i want to find the max id from this table.
    i.e.
    select max(id) from Student_master

    now this query, i want in LINQ what can be done and how plz reply
    its urgent.
    thanx.
    Wednesday, April 8, 2009 11:04 AM

Answers

  • Hello,

    (This really depends on the context but) you can get the Max value by doing 

    Student.Max(s=>s.id)

    L
    • Proposed as answer by Lenny S Wednesday, April 8, 2009 11:50 AM
    • Marked as answer by Dhrumil the Begginer Monday, April 13, 2009 6:13 AM
    Wednesday, April 8, 2009 11:50 AM

All replies

  • Hello,

    (This really depends on the context but) you can get the Max value by doing 

    Student.Max(s=>s.id)

    L
    • Proposed as answer by Lenny S Wednesday, April 8, 2009 11:50 AM
    • Marked as answer by Dhrumil the Begginer Monday, April 13, 2009 6:13 AM
    Wednesday, April 8, 2009 11:50 AM
  • this is not working but thanx for reply
    Thursday, April 9, 2009 6:11 AM
  • why does it not work? do you get an error? how are you creating your LINQ class(es)? Do you have all the right 'using' in place ie. System.Linq, etc...




    Thursday, April 9, 2009 11:31 AM
  • i m sorry it's working
    problem is that i am using "VB" and you have given me in c# so i was confused at that time therefor i wrote this is not working
    by the way my problem has been solved thanx.

    Monday, April 13, 2009 6:13 AM