none
Select MAX with parameter in EF4.0? RRS feed

  • Question

  • I'm trying to accomplish a query of "SELECT MAX(Col) FROM tbl WHERE ln = '@ln'; in EF 4.0.  How can I do this?  ExecuteStoreQuery didn't seem to return a correct result.


    http://sharepoint.nauplius.net
    Monday, December 12, 2011 1:46 AM

Answers

  • Hi Trevor;

    A Linq to EF query in the following form will return that you are looking for.

    [DataType] ln = SomeValue;
    
    var result = (from t in objectContext.tbl
                  where t.ln == ln
                  select t.Col).Max( );
    

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Monday, December 12, 2011 3:28 AM