Equivalent of SQL ISNULL in LINQ?
I am recently migrated from
I have problem in executing this query in Linq
select IsNull(MAX(InvoiceNo),0) from Sales
I have written this query in LINQ except isNull()
var q = (from p in dbContext.Sales select p.InvoiceNo).Max();
But i dont know how to use
IsNull() in this Linq
When i execute this Linq Query I am getting this exception.
'The invocation of the constructor on type 'JIMS.ViewModel.Transaction.SalesViewModel' that matches the specified binding constraints threw an exception.' Line number '8' and line position '6'.
I am using WPF MVVM FrameWork with Entity FrameWork as DAL
var InvoiceNo = dbContext.Sales.Max(x => (int?)x.InvoiceNo) ?? 0;
var q = (from p in dbContext.Sales select (int?)p.InvoiceNo).Max();