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.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    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();
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.