LINQ Code Explanation

Can anyone explain this piece of code?

(
From row In inputDT
Group row By k=row(“Reference”).ToString +"-"+ row(“Amount in local currency”).toString
Into grp = Group
Let conv =k.Split("-“c)(0).ToString
Let b = (
From r In Enumerable.Range(1, grp.Count)
Let a = If(grp.Count.Equals(1), New Object(){conv}, New Object(){conv+”."+r.ToString})
Select a
)
Select b
From rowArr In b
Select outDT.Rows.Add(rowArr)
).copyToDataTable

@Tanzill_Ahsan
requested code is a LINQ statement but not regex

Group the data from input by the reference and the currency
if the group has more then 1 members add a counter on the reference
add the result to outDT

it coulld look like

123 $
123 $
124 $
123 €

out:
123.1
123.2
124
123

in case of you would like to run this statement we would suggest to simplify it as well

@ppr

Thank you for your assistance. Can you please help me to create a sample Excel (input) file? I can share the xaml with you

just do one thing:

  • elaborate on you case in the form what is input data (share sample data with us) a
  • describe the expected output / what is to achieve

based on this we will help you to implement it.

Thanks for support

I have the xaml but I need to find out the possible input and output through the linq. In this case it is reversed.

I hope you understand the scenario. Thanks for your help.

@ppr

then answer was already given and you can start by following:
Input - inputDT

Reference Currency
123 $
123 $
124 $
125 $

Output - outDT Datastructure | e.g. prepare it with a build datatable acitvity:

Reference

Expected result:

Reference

123.1
123.2
124
125

@ppr

Thank you

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.