asif tariq

asif tariq

  • NA
  • 148
  • 17.4k

primitive type error in linq query

Mar 16 2020 1:17 PM
  1. public ActionResult CaseVolumeByTypeChartGraph()  
  2. {  
  3. MPOWERINGDBContext db = new MPOWERINGDBContext();  
  4. db.Configuration.ProxyCreationEnabled = false;  
  5. int ID = Convert.ToInt32(Session["UserId"]);  
  6. List mycompany = db.Companies.ToList();  
  7. List payr = db.Payers.ToList();  
  8. List cases = db.Cases.ToList();  
  9. List ptnt = db.Patients.ToList();  
  10. var multipletable = (from s in mycompany where s.UserID == ID select s).ToList();  
  11. //var query = db.Cases.Include("Patient")  
  12. var query = db.Cases.Include("Patient")  
  13. .Where(x => (mycompany.Select(y => y.CompanyID)).ToList()  
  14. .Contains(x.CompanyID ?? 0))  
  15. .GroupBy(p => new { p.DateOfService })  
  16. .Select(g => new CompanyUserViewModel  
  17. {  
  18. mydate = (DateTime)g.Key.DateOfService,  
  19. Eligiblechart = g.Count(w => w.Patient.InsuranceType == "Eligible"),  
  20. Otherchart = g.Count(w => w.Patient.InsuranceType == "Other")  
  21. }).ToList();  
Please anyone tell me why query not execute and return show 
 
Unable to create a constant value of type 'MPOWERING.Models.DB.Company'. Only primitive types or enumeration types are supported in this context.

Answers (4)