"And" condition in C#/LINQ Query

Posted by user1213055 on Stack Overflow See other posts from Stack Overflow or by user1213055
Published on 2012-03-20T04:36:17Z Indexed on 2012/03/20 5:29 UTC
Read the original article Hit count: 144

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ