Skip to content

Instantly share code, notes, and snippets.

@MichalGrzegorzak
Last active September 29, 2023 12:35
Show Gist options
  • Save MichalGrzegorzak/5fcbf6cb1086f146baafbf9733bcefa6 to your computer and use it in GitHub Desktop.
Save MichalGrzegorzak/5fcbf6cb1086f146baafbf9733bcefa6 to your computer and use it in GitHub Desktop.
Renaming duplicated elements
var groupedLines = lines.GroupBy(x => new { x.TRACType, x.Description })
.Where(z => z.Count() > 1)
.Select(x => x);
foreach (var grp in groupedLines)
{
int idx = 1;
foreach (BudgetLine budgetLine in grp)
{
budgetLine.Description = $"{budgetLine.Description} {idx}";
idx++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment