BEST
DEALS
OF THE
YEAR!
SAVE UP TO $3,000
LAST DAY 1 DEC
00 Days
00 Hrs
00 Min
00 Sec
Open Closed

share an entity that is owned by the host to all tenants #546


User avatar
0
khalid created

ABP Framework version: v3.2.0 UI type: Angular Tiered (MVC) or Identity Server Seperated (Angular): Identity Server Seperated (Angular) Exception message and stack trace: Steps to reproduce the issue:

I have same issue like this How to share an entity that is managed by the host but is accessible by tenants

public class Book: FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
        public virtual Guid? TenantId { get; set; } }

    public string BookName { get; set; }
}

How can  share an entity that is created  by the host to all tenants?

For example a tenant user should be able to see the list of books which is created by  himself and  by host. do I need to add Feature check? if so how?


2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    HI,

    This has nothing to do with Feature check, You need to query twice when you are querying the book list. example:

    public async Task<List<BookDto>> GetBooks()
    {
          var result = new List<BookDto>();
          // get the host's books
          using(CurrentTenant.Change(null))
          {
                 result.Add(await BookRepository.ToListAsync());
          }
          
          // get the tenant user's books
          result.Add(await BookRepository.ToListAsync());
    }
    
  • User Avatar
    0
    khalid created

    I got it thanks liangshiwei

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.1.0-preview. Updated on November 20, 2025, 09:12
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.