I have query in linq
and I want to convert that query in sql I am not very good in linq so can anyone help me to convert this query in sql:
We have ticket table and issues table ticket id is referenced in issue table :
var tickets = tickets.Where(x => x.Issues.Where(y => y.ResolutionDetails == "Resolved" &&
y.ResolvedwithSupplierDate == null).Count() == x.Issues.Count() && x.Issues.Count() > 0).ToList();
3
Answers
You can try using this tool – https://www.linqpad.net/. It may not be straightforward without setting up your data but perhaps may help. I think that changing the EF core logging levels may also help to see the SQL generated. (https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/simple-logging)
This is not an answer as such but just some suggestions. Hope it helps.
I hope this rewritten query will help you to understand what this query do:
It is trying to get the ticket where the resolution of the ticket is not equal to 0 and the ticket resolution count is equal to resolved count.
it uses the resolved as resolved tag. If it is not resolved then the resolvewithsupplier date would be null
Sql should be something like