Marius Vasile

Marius Vasile

  • 594
  • 1.9k
  • 144.7k

asp.net core ef count rows containing a specific data

Mar 19 2021 6:21 AM
I am trying to get data for a chart using 
 
  1. var getData = await _context.WOMains.Where(s => s.OrgID == orgid).Select(s => s.WOType).ToListAsync();  
  2.             foreach (var item in getData)  
  3.             {  
  4.                 WOMainChart = getData.Select(a => new WOChart  
  5.                 {  
  6.                     ChartData = item,  
  7.                     ChartValue = item.Count()  
  8.                 }).ToList();  
  9.             }  
In the table I have three disting WOType, each added only one time, so 3 rows in total. However, when I run the query I get 22 as a count for each. What am I doing wrong?

Answers (4)