Thanks :)
An example maybe? Where does that show? Thanks
But I don't need that filter for the reference data stored on Host.
So if I am doing a query that combines both data from host and Tenant 1, then knowing how IMayHaveTenant is removed, there won't be any WHERE clause to filter on Tenant for entities that don't implement that interface, only WHERE clause filter applies for entities with IMustHaveTenant.
I tried it and it works.
Thanks
That is correct if I am using ng-options to bind elements, but in my case I am just looping over items.
Check App/common/views/languages/texts.cshtml
Thanks Ismail.
SettingsManger calls SettingsStore to persist data into DB.
Who calls SettingsManager to persist? Where in time does this happen?
Thanks
So basically the problem is having that IMayHaveTenant filter, correct? In my case, I want to bring them and do joins to those tables irrespective of the tenant.
So removing the IMustHaveTenant filter should solve the issue here?
Thanks
Here you go:
public virtual IQueryable<Shelter> Shelters { get { return _repository.GetAll(); } }
Hi, I am looking at similar Razor views in the solution to see how to populate a select with live search. Below is the code. The problem is the select control is never populated, instead it shows "Nothing Selected".
I made sure data is returned from server. I can see them on the Chrome Developer Tool.
Thanks
View:
<select class="form-control bs-select" name="Shelter" id="Shelter" ng-model="vm.poc.shelter"
ui-jq="selectpicker"
data-live-search="true">
<option ng-repeat="shelter in vm.shelters"
value="{{shelter.id}}">{{shelter.label}}
</option>
</select>
<label>@L("Shelter")</label>
Controller:
vm.shelters = [];
vm.init = function () {
vm.loading = true;
commonLookupService.getReferenceTables().then(function (result) {
vm.shelters = result.data.shelters;
}).finally(function () {
vm.loading = false;
});
}
vm.init();
Hi, In the documentation it says the following.
So, if we are retrieving data for entities that have IMustHaveTenant, do we need to call SetTenantId explicitly? Isn't that retrieved from Session. Or is it a must to always call SetTenantId?
Thanks
Switching Between Host and Tenants
While working on a multitenant application database, we should know the current tenant. By default, it's obtained from IAbpSession (as described before). We can change this behaviour and switch to other tenant's database. Example:
public class ProductService : ITransientDependency
{
private readonly IRepository<Product> _productRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public ProductService(IRepository<Product> productRepository, IUnitOfWorkManager unitOfWorkManager)
{
_productRepository = productRepository;
_unitOfWorkManager = unitOfWorkManager;
}
[UnitOfWork]
public virtual List<Product> GetProducts(int tenantId)
{
using (_unitOfWorkManager.Current.SetTenantId(tenantId))
{
return _productRepository.GetAllList();
}
}
}
SetTenantId ensures that we are working on given tenant data, independent from database architecture:
If given tenant has a dedicated database, it switches to that database and gets products from it.
If given tenant has not a dedicated database (single database approach, for example), it adds automatic TenantId filter to query get only that tenant's products.
If we don't use SetTenantId, it gets tenantId from session, as said before.