Open Closed

Adding Tenant as navigation property #442


User avatar
0
khalid created

I have one- to-many relationship between the following two classes WorkRoleTenantAssignment and Tenant.

I trying to get all WorkRoleTenantAssignment with Tenant Because tenant is an aggregate root and adding navigation property to aggregate roots is not allowed in Abp, I added new class below, similar to the classes generated by Abp suite

And I wrote the following Linq query to fetch data Work Roles Assignments along with their assigned tenants. When I run the code I got this following error: I have tried many ways to overcome this issue but with no luck. Your guidance is appreciated.


1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi, try:

    var tenants = await _tenantRepository.GetListAsync();
    
    var result = await _workRoleTenantAssignments.Where(x => tenants.Select(t => t.Id).Contains(x.TenantId.Value)).ToListAsync();
    
    tenants = tenants.TakeWhile(t => result.Select(r => r.TenantId).Contains(t.Id)).ToList();
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09