0

I am loading the child entity UserStarted from my TransactionDetails

var result = (from A in context.Transactions.Include(_ => _.TransactionDetails.Select(us => us.UserStarted))
              select A).SingleOrDefault();

Now I want to load another entity, but I don't know how. The entity is similar to UserStarted, it's the UserEnded also from TransactionDetails

Thank you very much

2 Answers 2

1

You can chain multiple include predicates together:

var result = context.Transactions
  .Include(transaction => transaction.TransactionDetails.Select(us => us.UserStarted))
  .Include(transaction => transaction.TransactionDetails.Select(us => us.UserEnded))
  .SingleOrDefault();
Sign up to request clarification or add additional context in comments.

Comments

1

You can also try

 var result = (from A in context.Transactions.Include(_ => _.TransactionDetails.Select(us => new { UserStarted  = us.UserStarted, UserEnded = us.UserEnded }))
select A).SingleOrDefault();

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.