From the following code, patientlocallist is List<Patient>.
var pat = patientlocallist.FirstOrDefault(p => p.PatientID == Convert.ToDouble(patient.PatientID));
if (pat != null)//exist in the Active Patient List
When the patientlocallist.FirstOrDefault() returns nothing, an error occur from next line(if (pat!=null)) like following.
System.NullReferenceException:'Object reference not set to an instance of an object'
How to check if a List<T>.FirstOrDefault() returns nothing?