Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RavenDb : LoadAsync with Include returns null

Tags:

ravendb

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.

like image 261
Galhem Avatar asked Apr 11 '26 18:04

Galhem


1 Answers

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.

like image 192
Ayende Rahien Avatar answered Apr 20 '26 20:04

Ayende Rahien