1

Can anyone explain why this query would return 12 companies (it has 12 UserAccessList children)

var list = session.QueryOver<Company>()
        .Where(x => x.Id == 1) //x => x.Id.IsIn(ids))
        .Fetch(l => l.UserAccessList).Eager()
        .List<Company>();
1

2 Answers 2

2

Because in SQL its going to be something like:

select * from 
Companies c left outer join UserAccessLists uac on c.Id == uac.CompanyId
where c.id = id

And it is giving duplicates in results. How to fix such issues you can read here.

Sign up to request clarification or add additional context in comments.

Comments

1

This also works

var c = session.QueryOver<Company>()
        .Future();

 session.QueryOver<Company>()
        .Fetch(l => l.UserAccessList).Eager()
        .Future();

var list = c.ToList();

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.