0

Hi i have a DataTable with following data formating. I am trying to aggregate in C# on condition. I am a Newbie to Linq.

Profile | Nr   | Result| 
------------------------
A       | 1    | OK    |  
A       | 2    | NOK   | 
A       | 2    | OK    | 
A       | 3    | OK    | 
A       | 4    | OK    | 
A       | 5    | OK    | 
BB      | 1    | OK    |  
BB      | 2    | NOK   | 
BB      | 2    | NOK   | 
BB      | 2    | OK    | 
BB      | 3    | OK    |
BB      | 4    | OK    | 
BB      | 5    | OK    | 

I Want to aggregate by first columnt (Profile) and count rows where the Result is OK. The expected result should be a new DataTable and should look like this.

Profile | Count| 
----------------
A       | 5    |   
BB      | 5    |  

How can i do this in C# ?

aybe
  • 15,516
  • 9
  • 57
  • 105
  • 1
    https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/creating-a-datatable-from-a-query-linq-to-dataset – aybe Jan 29 '20 at 15:18
  • https://stackoverflow.com/questions/9258704/how-to-group-by-the-datatable-and-put-the-result-in-another-datatable – yob Jan 29 '20 at 16:01

0 Answers0