|
@@ -106,10 +106,13 @@ public class SnapshotUserApplication : ISnapshotUserApplication, IScopeDependenc
|
|
{
|
|
{
|
|
var query = _citizenRepository.Queryable(includeDeleted: true)
|
|
var query = _citizenRepository.Queryable(includeDeleted: true)
|
|
.LeftJoin<ThirdAccount>((citizen, third) => citizen.Id == third.ExternalId)
|
|
.LeftJoin<ThirdAccount>((citizen, third) => citizen.Id == third.ExternalId)
|
|
- .LeftJoin<CitizenRelationSafetyType>((citizen, third, relation) => relation.CitizenId == citizen.Id)
|
|
|
|
|
|
+ .LeftJoin<CitizenRelationSafetyType>((citizen, third, relation) => relation.CitizenId == citizen.Id && relation.SafetyTypeId == dto.SafetyTypeId)
|
|
.WhereIF(dto.PhoneNumber.NotNullOrEmpty(), (citizen, third) => citizen.PhoneNumber.Contains(dto.PhoneNumber))
|
|
.WhereIF(dto.PhoneNumber.NotNullOrEmpty(), (citizen, third) => citizen.PhoneNumber.Contains(dto.PhoneNumber))
|
|
- .WhereIF(dto.SafetyTypeId.NotNullOrEmpty(), (citizen, third, relation) => relation.SafetyTypeId == dto.SafetyTypeId && relation.CitizenId == null)
|
|
|
|
- .Select((citizen, third, relation) => new GetThirdCitizenOutDto { CitizenId = citizen.Id}, true);
|
|
|
|
|
|
+ .WhereIF(dto.SafetyTypeId.NotNullOrEmpty(), (citizen, third, relation) => relation.CitizenId == null)
|
|
|
|
+ .Select((citizen, third, relation) => new GetThirdCitizenOutDto
|
|
|
|
+ {
|
|
|
|
+ CitizenId = citizen.Id
|
|
|
|
+ }, true);
|
|
#if DEBUG
|
|
#if DEBUG
|
|
var sql = query.ToSqlString();
|
|
var sql = query.ToSqlString();
|
|
#endif
|
|
#endif
|