I am working on this query in my sql server
select a.care_type_id, a.description,
isChecked = case when b.care_type_id is null then 'false' else 'true' end
from caretype a
left join patientinsurancetacitem b on a.care_type_id = b.care_type_id and
b.tac_id = 1
I want to translate the query into LINQ. However, I am having trouble with the and
operator. I have this code so far;
from a in context.CareTypes
join b in context.PatientInsuranceTACItems on a.care_type_id equals
b.care_type_id into x
from xx in x.Where(w => w.tac_id == 1).DefaultIfEmpty()
select new {
isChecked = (b.care_type_id == null ? false : true),
care_type_id = a.care_type_id,
description = a.description}
And, also, I cannot get the b
that I equated in isChecked
variable. From where will I start modifying in order to get the same result as my sql query? In where I got it wrong?