ปรับให้จัด group ตามที่กรอง (#1858)

Co-authored-by: harid <harid_pr61@live.rmutl.com>
This commit is contained in:
Harid Promsri 2025-10-09 16:49:10 +07:00 committed by GitHub
parent fe4a174bf7
commit 5f0a0b1a46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,