Browse Source

Add `GetListByIdsAsync` method to `IIdentityUserRepository`.

pull/15892/head
maliming 4 years ago
parent
commit
8b8c750dc0
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 6
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs
  2. 6
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityLinkUserRepository.cs
  3. 8
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
  4. 7
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

6
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs

@ -125,4 +125,10 @@ public interface IIdentityUserRepository : IBasicRepository<IdentityUser, Guid>
bool includeDetails = true,
CancellationToken cancellationToken = default
);
Task<List<IdentityUser>> GetListByIdsAsync(
IEnumerable<Guid> ids,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
}

6
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityLinkUserRepository.cs

@ -20,6 +20,7 @@ public class EfCoreIdentityLinkUserRepository : EfCoreRepository<IIdentityDbCont
public virtual async Task<IdentityLinkUser> FindAsync(IdentityLinkUserInfo sourceLinkUserInfo, IdentityLinkUserInfo targetLinkUserInfo, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.AsNoTracking()
.OrderBy(x => x.Id).FirstOrDefaultAsync(x =>
x.SourceUserId == sourceLinkUserInfo.UserId && x.SourceTenantId == sourceLinkUserInfo.TenantId &&
x.TargetUserId == targetLinkUserInfo.UserId && x.TargetTenantId == targetLinkUserInfo.TenantId ||
@ -31,7 +32,8 @@ public class EfCoreIdentityLinkUserRepository : EfCoreRepository<IIdentityDbCont
public virtual async Task<List<IdentityLinkUser>> GetListAsync(IdentityLinkUserInfo linkUserInfo, List<IdentityLinkUserInfo> excludes = null,
CancellationToken cancellationToken = default)
{
IQueryable<IdentityLinkUser> query = (await GetDbSetAsync())
var query = (await GetDbSetAsync())
.AsNoTracking()
.Where(x =>
x.SourceUserId == linkUserInfo.UserId && x.SourceTenantId == linkUserInfo.TenantId ||
x.TargetUserId == linkUserInfo.UserId && x.TargetTenantId == linkUserInfo.TenantId);
@ -51,7 +53,7 @@ public class EfCoreIdentityLinkUserRepository : EfCoreRepository<IIdentityDbCont
public virtual async Task DeleteAsync(IdentityLinkUserInfo linkUserInfo, CancellationToken cancellationToken = default)
{
var linkUsers = await (await GetDbSetAsync()).Where(x =>
var linkUsers = await (await GetDbSetAsync()).AsNoTracking().Where(x =>
x.SourceUserId == linkUserInfo.UserId && x.SourceTenantId == linkUserInfo.TenantId ||
x.TargetUserId == linkUserInfo.UserId && x.TargetTenantId == linkUserInfo.TenantId)
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));

8
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs

@ -348,4 +348,12 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
GetCancellationToken(cancellationToken)
);
}
public virtual async Task<List<IdentityUser>> GetListByIdsAsync(IEnumerable<Guid> ids, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(x => ids.Contains(x.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
}

7
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

@ -316,4 +316,11 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
GetCancellationToken(cancellationToken)
);
}
public virtual async Task<List<IdentityUser>> GetListByIdsAsync(IEnumerable<Guid> ids, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(x => ids.Contains(x.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
}

Loading…
Cancel
Save