Link to home
Create AccountLog in
Avatar of sbornstein2
sbornstein2

asked on

LINQ statement help should be rather simple

Hello all,

I am using entity framework and I have entities with navigation properties aka table keys.   I have the following statement:

var loans = _uow.Loans.GetAll().Where(loan => loan.PoolID == poolId
                   && loan.IsActive && (!loan.LoanWorkflows.All(lw => lw.LoanId == loan.LoanID && 
                         lw.PoolWorkflowId == poolWorkflow.PoolWorkflowId)));

This is not working as I am expecting.   So what I want is I want all active Loans from the Loans table that do not have a corresponding record in the LoanWorkflows table where Loan.LoanId = LoanWorkflow.LoanId and LoanWorkflow.PoolWorkFlowId = the passed in value I have above for that.   Also there might not be at all a LoanWorkflowId object it may be null but I think that would be handled.   My statement right now is not working right for example if I have a truncated LoanWorkflow table I am getting 0 loans back that is not right.

Thanks all.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of sbornstein2
sbornstein2

ASKER

thank you
Not a problem, glad I was able to help.