From 5f0a0b1a46e53f0e9e2f45ea0956f747ba5326e0 Mon Sep 17 00:00:00 2001 From: Harid Promsri <52228846+Harid-999@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:49:10 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B9=83?= =?UTF-8?q?=E0=B8=AB=E0=B9=89=E0=B8=88=E0=B8=B1=E0=B8=94=20group=20?= =?UTF-8?q?=E0=B8=95=E0=B8=B2=E0=B8=A1=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=81?= =?UTF-8?q?=E0=B8=A3=E0=B8=AD=E0=B8=87=20(#1858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: harid --- .../LeaveRequests/LeaveRequestRepository.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs index 84b0d84e..c6d9bdc7 100644 --- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs @@ -1563,10 +1563,21 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests var organizationName = $"{org.Root ?? ""}{(!string.IsNullOrEmpty(org.Child1) ? "/" + org.Child1 : "")}{(!string.IsNullOrEmpty(org.Child2) ? "/" + org.Child2 : "")}{(!string.IsNullOrEmpty(org.Child3) ? "/" + org.Child3 : "")}{(!string.IsNullOrEmpty(org.Child4) ? "/" + org.Child4 : "")}"; if (data.Count > 0) { - var res = (from d in data + var grouped = data.GroupBy(d => nodeByReq switch + { + 0 => d.Root, + 1 => d.Child1, + 2 => d.Child2, + 3 => d.Child3, + 4 => d.Child4, + _ => d.Root + }); + var res = (/*from d in data group d by new { d.Root, d.Child1, d.Child2, d.Child3, d.Child4 } into grp - orderby grp.Key.Root, grp.Key.Child1, grp.Key.Child2, grp.Key.Child3, grp.Key.Child4 - select new GetSumApproveLeaveByRootDto + orderby grp.Key.Root, grp.Key.Child1, grp.Key.Child2, grp.Key.Child3, grp.Key.Child4*/ + from grp in grouped + orderby grp.Key + select new GetSumApproveLeaveByRootDto { //Root = $"{grp.Key.Root}{(!string.IsNullOrEmpty(grp.Key.Child1) ? "/" + grp.Key.Child1 : "")}{(!string.IsNullOrEmpty(grp.Key.Child2) ? "/" + grp.Key.Child2 : "")}{(!string.IsNullOrEmpty(grp.Key.Child3) ? "/" + grp.Key.Child3 : "")}{(!string.IsNullOrEmpty(grp.Key.Child4) ? "/" + grp.Key.Child4 : "")}", Root = organizationName,