CreateFilteredQuery using multiple contexts
See original GitHub issue- Abp package version - 7
- Base framework - .Net Core.
- Exception message -
The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'. Only providers that implement 'IAsyncQueryProvider' can be used for Entity Framework asynchronous operations.
Hey Guys,
I cant seem to figure out the solution to this issue. Im using a context per tenant and obviously one for the host. Im also creating a dbset only on the tenants but i need to display it in a list on the host. I have figured out how to achieve this for the most part but i cant seem to figure out how to return a filtered IQueryable for the pagination and sorting/filtering of the list. Seems to me that i cant convert the generic list to an iQueryable and im not sure how to get around that.
For context, i simply want to display a list of licences from all tenants on the host. My actions work already to do what i need with them, this is the only thing i cant get around.
Below is the method im using and above is the error i receive.
Would really appreciate the help if possible.
Cheers for any help in advance, let me know if i can provide anything else to help.
protected override IQueryable<Licence> CreateFilteredQuery(PagedLicenceManagerResultRequestDto input)
{
var loggedInUser = _userManager.GetUserById((int)AbpSession.UserId);
var adminUser = loggedInUser.NormalizedEmailAddress.Contains("SUPPORT");
var licences = new List<Licence>();
var tenants = _tenantRepository.GetAllList(t => t.ConnectionString != null && t.ConnectionString != "");
var builder = new DbContextOptionsBuilder<TenantContext>();
try
{
foreach (Tenant tenant in tenants)
{
TenantContextConfigurer.Configure(builder, SimpleStringCipher.Instance.Decrypt(tenant.ConnectionString));
using (var context = new TenantContext(builder.Options))
{
licences.AddRange(context.Licenses);
}
}
}
catch
{
return null;
}
var query = licences.AsQueryable();
var test = query.WhereIf(!input.Keyword.IsNullOrWhiteSpace(), x => x.AssignedTo.Contains(input.Keyword) || x.LicenceType.ToString().Contains(input.Keyword));
return test;
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
@ismcagdas thats a good idea, ill impliment that, then it should solve my paging issue aswell! Tyvm!
If that’s the case, you can use Domain Events and create a host side entity (a new entity which is copy of License entity) when a tenant side License entity is created. In that way, a host user can easily query License records.
We are using a similar approach for keeping a list of all users on Host database, see https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Zero.Common/Authorization/Users/UserAccountSynchronizer.cs