Browse Source

Fix possible `null` errors.

Resolve #17766
pull/17769/head
maliming 3 years ago
parent
commit
d32e8a090f
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  2. 2
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs
  3. 9
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/OrganizationUnitRepository_Tests.cs

2
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

@ -40,7 +40,7 @@ public class EfCoreOrganizationUnitRepository
{
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId.Value)
.Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId)
.ToListAsync(GetCancellationToken(cancellationToken));
}

2
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs

@ -39,7 +39,7 @@ public class MongoOrganizationUnitRepository
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId.Value)
.Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId)
.ToListAsync(GetCancellationToken(cancellationToken));
}

9
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/OrganizationUnitRepository_Tests.cs

@ -47,8 +47,13 @@ public abstract class OrganizationUnitRepository_Tests<TStartupModule> : AbpIden
[Fact]
public async Task GetAllChildrenWithParentCodeAsync()
{
(await _organizationUnitRepository.GetAllChildrenWithParentCodeAsync(OrganizationUnit.CreateCode(0),
_guidGenerator.Create())).ShouldNotBeNull();
var allChildren = await _organizationUnitRepository.GetAllChildrenWithParentCodeAsync(OrganizationUnit.CreateCode(0), _guidGenerator.Create());
allChildren.ShouldNotBeNull();
allChildren.ShouldBeEmpty();
allChildren = (await _organizationUnitRepository.GetAllChildrenWithParentCodeAsync(OrganizationUnit.CreateCode(1), null));
allChildren.ShouldNotBeNull();
allChildren.ShouldNotBeEmpty();
}
[Fact]

Loading…
Cancel
Save