(
From row In dt_Input.AsEnumerable()
Group row By k=row("Id").ToString.Trim
Into grp=Group
Let mindr = grp.OrderBy(Function(gr) gr("Date 1")).First()
Let maxdr = grp.OrderByDescending(Function(gr) gr("Date 2")).First()
Let d1 = mindr("Date 1")
Let d2 = maxdr("Date 2")
Let amt1 = mindr("Amount 1 ")
Let amt2 = maxdr("Amount 2")
Select dt_Input.LoadDataRow({k, d1, d2, amt1, amt2}, True)
).CopyToDataTable
Is it possible to replace same thing in this expression?
(From d In DtRead.AsEnumerable
Group d By k=d("Id").toString.Trim Into grp = Group
Let IncMin = String.Join(" ",CDate(grp.Min(Function (n) n("Date 1").toString.Trim)).ToString("dd.MM.yyyy"))
Let SfMax = String.Join(" ",CDate(grp.Max(Function (M) M ("Date 2").ToString.Trim)).ToString("dd.MM.yyyy"))
Let Sa = IncMin(3)
Let Sa1 = IncMin(4)
Let ra = New Object(){k,IncMin,SfMax,Sa,Sa1}
Select r = DtClone.Rows.Add(ra)).CopyToDataTable
(
From row In dtRead.AsEnumerable()
Group row By k=row("Id").ToString.Trim
Into grp=Group
Let mindr = grp.OrderBy(Function(gr) gr("Date 1")).First()
Let maxdr = grp.OrderByDescending(Function(gr) gr("Date 2")).First()
Let d1 = mindr("Date 1")
Let d2 = maxdr("Date 2")
Let amt1 = mindr("Amount 1 ")
Let amt2 = maxdr("Amount 2")
Let ra = New Object(){k, d1, d2, amt1, amt2}
Select r = DtClone.Rows.Add(ra)
).CopyToDataTable