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);
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)
7 Answer(s)
-
0
var organizationUnits = await _organizationUnitRepository .GetAllIncluding(ou => ou.Children) .Where(ou => organizationUnitIds.Contains(ou.Id)) .ToListAsync();Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
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?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Yes, if you want to use the code from the documentation. Otherwise, you can write your own join query.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Can you please show me how to write that query where i get the current user, users OU´s including its children?
Thanks.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @pointlevel
Have you managead to write that query ?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Copy the query in
GetOrganizationUnitsAsyncand make this change:- _organizationUnitRepository.GetAll() + _organizationUnitRepository.GetAllIncluding(ou => ou.Children)Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Thank you aaron simplicity is the best!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)