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
parent
commit
dc19b986cd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs

21
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs

@ -64,20 +64,17 @@ namespace Volo.CmsKit.Tags
Guid? tenantId = null,
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>()
.Where(x =>
x.EntityId == entityId &&
x.TenantId == tenantId
)
.Join(
DbSet,
o => o.TagId,
i => i.Id,
(entityTag, tag) => tag)
.Where(x => x.EntityType == entityType);
var query = DbSet
.Where(x => x.EntityType == entityType &&
x.TenantId == tenantId &&
entityTagIds.Contains(x.Id));
return await query.ToListAsync();
return await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
}
}
}

Loading…
Cancel
Save