3
votes

I was adding some async calls in my project when i've encountered a problem. The same call between Session and AsyncSession doesn't return my document.

Here the document :

class Company {
    string Id;
    string Name;
    BusinessUnit BusinessUnit;
}

class BusinessUnit {
    string Name;
    List<BusinessUnit> BusinessUnits;
    List<Employee> Employees;
}

class Employee {
    string Position;
    string UserId;
}

class User {
    string Id;
    string FullName;
}

User and Company are two collections in my RavenDb. As you can see, we have a tree of business unit in our document Company. So when i want to load a Company, i make this call :

var company = Session.Include<Employee, User>(x => x.UserId)
    .Load<Company>(companyId); //Working like a charm

But when i tried to do the same with Async :

var company = await AsyncSession.Include<Employee, User>(x => x.UserId)
    .LoadAsync<Company>(companyId); //company is null

var company = await AsyncSession.LoadAsync<Company>(companyId); //This is working

I can't see why it isn't working.

During my searching of answers, i've found a small difference between the implementation of MultiLoaderWithInclude and AsyncMultiLoaderWithInclude. I don't know if my issue can be resolved by these classes.

2
Can you submit a failing test to the mailing list? This should work. Anything that is returned from Load should be returned from Load/Include. See how to submit a failing test here: ravendb.net/docs/article-page/3.5/Csharp/server/troubleshooting/… - Ayende Rahien
I've posted a failing test ! - Galhem

2 Answers

2
votes

Thanks for the failing test. The underlying reason is that you are using fields in there, not properties. This is a bug in the client which will be fixed shortly, but in the meantime you can use properties and avoid it entirely.

0
votes

This won't load the related User documents in a single request. You can do something like this:

var company = session.Include<Company, User>(x => x.BusinessUnit.Employees.Select(y => y.UserId)).Load<Company>(companyId);