Browse Source
Merge pull request #18555 from abpframework/liangshiwei/identitypatch
Add GetListByNamesAsync to IIDentityClaimTypeRepository
pull/18556/head
Engincan VESKE
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
27 additions and
0 deletions
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIDentityClaimTypeRepository.cs
-
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs
-
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs
-
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs
|
|
@ -35,4 +35,9 @@ public interface IIdentityClaimTypeRepository : IBasicRepository<IdentityClaimTy |
|
|
string filter = null, |
|
|
string filter = null, |
|
|
CancellationToken cancellationToken = default |
|
|
CancellationToken cancellationToken = default |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
Task<List<IdentityClaimType>> GetListByNamesAsync( |
|
|
|
|
|
IEnumerable<string> names, |
|
|
|
|
|
CancellationToken cancellationToken = default |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
@ -58,4 +58,11 @@ public class EfCoreIdentityClaimTypeRepository : EfCoreRepository<IIdentityDbCon |
|
|
u.Name.Contains(filter) |
|
|
u.Name.Contains(filter) |
|
|
).LongCountAsync(GetCancellationToken(cancellationToken)); |
|
|
).LongCountAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<IdentityClaimType>> GetListByNamesAsync(IEnumerable<string> names, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await (await GetDbSetAsync()) |
|
|
|
|
|
.Where(x => names.Contains(x.Name)) |
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -68,4 +68,11 @@ public class MongoIdentityClaimTypeRepository : MongoDbRepository<IAbpIdentityMo |
|
|
.As<IMongoQueryable<IdentityClaimType>>() |
|
|
.As<IMongoQueryable<IdentityClaimType>>() |
|
|
.LongCountAsync(GetCancellationToken(cancellationToken)); |
|
|
.LongCountAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<IdentityClaimType>> GetListByNamesAsync(IEnumerable<string> names, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken)) |
|
|
|
|
|
.Where(x => names.Contains(x.Name)) |
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -42,4 +42,12 @@ public abstract class IdentityClaimTypeRepository_Tests<TStartupModule> : AbpIde |
|
|
{ |
|
|
{ |
|
|
(await ClaimTypeRepository.GetCountAsync("Age")).ShouldBe(1); |
|
|
(await ClaimTypeRepository.GetCountAsync("Age")).ShouldBe(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task GetListAsyncByNames() |
|
|
|
|
|
{ |
|
|
|
|
|
var result = await ClaimTypeRepository.GetListByNamesAsync(new List<string> { "Age", "Education" }); |
|
|
|
|
|
|
|
|
|
|
|
result.Count.ShouldBe(2); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|