0
pointlevel created
Hello!
How can i retrieve(Include) the Children as iCollection of OrganizationUnits when using this code from documentation?
var user = await _userManager.GetUserByIdAsync(AbpSession.UserId.Value);
var organizationUnits = await _userManager.GetOrganizationUnitsAsync(user);
var organizationUnitIds = organizationUnits.Select(ou => ou.Id);
7 Answer(s)
-
0
var organizationUnits = await _organizationUnitRepository .GetAllIncluding(ou => ou.Children) .Where(ou => organizationUnitIds.Contains(ou.Id)) .ToListAsync();
-
0
so i need to make an additional query for that? First get the logged in user, then the OUs for that user, and then the OUs again with children?
-
0
Yes, if you want to use the code from the documentation. Otherwise, you can write your own join query.
-
0
Can you please show me how to write that query where i get the current user, users OU´s including its children?
Thanks.
-
0
Hi @pointlevel
Have you managead to write that query ?
-
0
Copy the query in
GetOrganizationUnitsAsync
and make this change:- _organizationUnitRepository.GetAll() + _organizationUnitRepository.GetAllIncluding(ou => ou.Children)
-
0
Thank you aaron simplicity is the best!