Max in linq to NHibernate for not exist data in database
c#, linq, linq-to-nhibernate, max, nhibernate
Solution
Try this
SessionInstance.Query<Request>().Max(x => (int?)x.Code);
Problem
I have a query by linq to NHibernate. ``` var q = SessionInstance.Query<Request>().Max(e => e.Code); ``` If `Request` table has no rows, execution of this query raises GenericADOException with this message : `{"Could not execute query[SQL: SQL not available]"}` `{"Value cannot be null.\r\nParameter name: item"}` What should I do?