user8519946
user8519946

Reputation:

Convert datatable to another datatable By Linq C#?

i have a Datatable in which there are Columns are
Assigned to
Storyid,
Completed,
Effort.
assigned to person can have Same Storyid with diffrent or same (Completed,Effort hours)(image attached)

input datatable

i want dataTable to like in this form where Assigned to Effort and completed hours will be Sum and there storyid's(image attached below
output datatable

Upvotes: 0

Views: 47

Answers (1)

G_S
G_S

Reputation: 7110

I hope this is what you are looking for

 var result = yourDatatable
      .GroupBy(e => e.AssignedTo)
      .ToList()
      .Select(eg => new
      {
          AssignedTo = eg.Key,
          CompletedSum = eg.Sum(p=>p.completed),
          EfforSum = eg.Sum(p=>p.effort),
          StoryIds = string.Join(",", eg.Select(i => i.storyid))
      });

Upvotes: 2

Related Questions