diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 68fbf57d..136d5701 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -718,7 +718,7 @@ namespace BMA.EHR.Application.Repositories.Commands var seq = 1; // เอาชื่อของกรรมการ ไปหาจากทะเบียนประวัติ - var p1 = await _dbContext.Set() + var p1 = (await _dbContext.Set() .Include(x => x.Prefix) .Select(x => new { @@ -729,7 +729,8 @@ namespace BMA.EHR.Application.Repositories.Commands lastName = x.LastName, fullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}" }) - .FirstOrDefaultAsync(x => x.fullName == command.ChairManFullName); + .ToListAsync()) + .FirstOrDefault(x => x.fullName == command.ChairManFullName); if (p1 != null) { @@ -746,7 +747,7 @@ namespace BMA.EHR.Application.Repositories.Commands result.Add(receiver); } - var p2 = await _dbContext.Set() + var p2 = (await _dbContext.Set() .Include(x => x.Prefix) .Select(x => new { @@ -757,7 +758,8 @@ namespace BMA.EHR.Application.Repositories.Commands lastName = x.LastName, fullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}" }) - .FirstOrDefaultAsync(x => x.fullName == command.Member1FullName); + .ToListAsync()) + .FirstOrDefault(x => x.fullName == command.Member1FullName); if (p2 != null) { @@ -774,7 +776,7 @@ namespace BMA.EHR.Application.Repositories.Commands result.Add(receiver); } - var p3 = await _dbContext.Set() + var p3 = (await _dbContext.Set() .Include(x => x.Prefix) .Select(x => new { @@ -785,7 +787,8 @@ namespace BMA.EHR.Application.Repositories.Commands lastName = x.LastName, fullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}" }) - .FirstOrDefaultAsync(x => x.fullName == command.Member2FullName); + .ToListAsync()) + .FirstOrDefault(x => x.fullName == command.Member2FullName); if (p3 != null) {