Browse Source
Merge pull request #6851 from abpframework/cms-kit/content-management-tag-efcore-query
Cms kit - Tags EfCore Query Update
pull/6756/head
Enis Necipoglu
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
9 additions and
12 deletions
-
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs
|
|
@ -64,20 +64,17 @@ namespace Volo.CmsKit.Tags |
|
|
Guid? tenantId = null, |
|
|
Guid? tenantId = null, |
|
|
CancellationToken cancellationToken = default) |
|
|
CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var entityTagIds = await DbContext.Set<EntityTag>() |
|
|
|
|
|
.Where(q => q.EntityId == entityId && q.TenantId == tenantId) |
|
|
|
|
|
.Select(q => q.TagId) |
|
|
|
|
|
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
|
|
|
|
|
|
var query = DbContext.Set<EntityTag>() |
|
|
var query = DbSet |
|
|
.Where(x => |
|
|
.Where(x => x.EntityType == entityType && |
|
|
x.EntityId == entityId && |
|
|
x.TenantId == tenantId && |
|
|
x.TenantId == tenantId |
|
|
entityTagIds.Contains(x.Id)); |
|
|
) |
|
|
|
|
|
.Join( |
|
|
|
|
|
DbSet, |
|
|
|
|
|
o => o.TagId, |
|
|
|
|
|
i => i.Id, |
|
|
|
|
|
(entityTag, tag) => tag) |
|
|
|
|
|
.Where(x => x.EntityType == entityType); |
|
|
|
|
|
|
|
|
|
|
|
return await query.ToListAsync(); |
|
|
return await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|