"And" condition in C#/LINQ Query
- by user1213055
partial void PrintDocLetter1_CanExecute(ref bool result)
{
if (this.PatientsMasterItem.DoctorsMasterItem != null)
{
var Doctor = PatientsMasterItem.DoctorsMasterItem;
var PatientList = Doctor.PatientsMasterItem;
var Letters = PatientsMasterItem.LettersSentItem;
if ((PatientList.Count() > 1) && (Letters.Any(i => i.LetterType == "DoctorLetter1")))
{
result = false;
}
else
{
result = true;
}
}
}
I think something is wrong with my second condition. I'm trying to find two things.
1) Doctors with more than 1 patient.
2) Among those patients whether a lettertype called "DoctorLetter1" has been sent or not.
The above code is working good for that particular record but not working other patients with same doctors where patient1 has already been sent with DoctorLetter1.