I'm doing a simple Pie chart that counts current employee, I'm still new to LINQ so I just want to ask is there a way to total count null values?
Here's my code so far:
public ActionResult PieCount()
{
int undefined = db.EMPs.Where(x => x.JS_REF == 1).Count();
int regular = db.EMPs.Where(x => x.JS_REF ==2 ).Count();
int contractual = db.EMPs.Where(x => x.JS_REF == 3).Count();
int probationary = db.EMPs.Where(x => x.JS_REF ==4 ).Count();
int notdefined = db.EMPs.Where(x => x.JS_REF == null ).Count();
Ratio obj = new Ratio();
obj.Undefined = undefined;
obj.Contractual = contractual;
obj.Regular = regular;
obj.Probationary = probationary;
obj.Notdefined = notdefined;
return Json(new { result = obj }, JsonRequestBehavior.AllowGet);
}
It's working so far but when I tried to count null value "x.JS_REF == null" I'm getting an error
here's the error: enter image description here
My database: enter image description here