0

I have a Linq query to get all clients who have invoices which are overdue with more than 30 days.

When i run the query below it does not return any results and if i remove the a.Status it returns the results.

var clients = (from a in ClientTable
           join b in Invoices on a.ClientId equals b.InvoiceId
           where DbFunctions.DiffDays(TodayDate, b.InvoiceDueDate) > 30 && a.Status == "Active"
           group a into c by a.id   
           select c).ToList();

Please help

2
  • Does the result without the a,Status == "Active" constraint return data with that specified status? Commented Mar 5, 2018 at 8:54
  • Yes it does return the results with the active status and all other statuses including the ones which have a NULL status. Commented Mar 5, 2018 at 9:04

1 Answer 1

0

It looks like the presence of NULL values in the status column where an issue.Resolved it by including object.Equals(customer.Status,"Active") as per this post Handling null values in where clause using LINQ-to-SQL

var clients = (from a in ClientTable
           join b in Invoices on a.ClientId equals b.InvoiceId
           where DbFunctions.DiffDays(TodayDate, b.InvoiceDueDate) > 30 && object.Equals(a.Status,"Active")
           group a into c by a.id   
           select c).ToList();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.