瀏覽代碼

Merge branch 'feature/snapshot' into test

qinchaoyue 17 小時之前
父節點
當前提交
2cad7bb60e
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/Hotline.Application/Snapshot/SnapshotUserApplication.cs

+ 6 - 3
src/Hotline.Application/Snapshot/SnapshotUserApplication.cs

@@ -106,10 +106,13 @@ public class SnapshotUserApplication : ISnapshotUserApplication, IScopeDependenc
     {
         var query = _citizenRepository.Queryable(includeDeleted: true)
             .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.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
         var sql = query.ToSqlString();
 #endif