Data collection between ages in mvc5

Dec 6 2018 10:51 AM
hi guys I have tried to collect data between ages but there is an error I do not know why here is my code my controller
  1. public ActionResult AllCuont()  
  2. { var query = (from t in db.Pations  
  3. let range = ( t.Age >= 0 && t.Age < 10 ? "0-9" :  
  4. t.Age >= 11 && t.Age < 15 ? "10-14" :  
  5. t.Age >= 15 && t.Age < 50 ? "15-50" : "50+" )  
  6. group t by range into g  
  7. select new UserRange { AgeRange = g.Key, Count = g.Count() }).ToList(); //add the sum column.  
  8. query.Add(new UserRange() { AgeRange = "Sum", Count = query.Sum(c => c.Count) }); ViewBag.UserData = query;  
  9. return View(); }  
and this is my model for To collect value
  1. namespace Archive.Models  
  2. {  
  3. public class UserRange {  
  4. public string AgeRange { getset; }  
  5. public IEnumerable<Pation> Count { getset; } }  
  6. }  
i Can't find the problem can you help me
the problem in my controller here

Answers (1)