I have the following Two tables.
Person : { PersonId, FirstName, LastName}
Phone : { PhoneId, PersonIdFK, Number, IsActive}
In a classic SQL, you would write the following SQL statement to retrieve data and active phone numbers for a given person.
SELECT PersonId,FirstName, LastName, PhoneId, Number
FROM Person left outer join Phone
ON Person.PersonId = Phone.PersonIdFK and IsActive=1
Where PersonId=123
Question:
How can I achieve this SQL statemnet in Entity Framework (LINQ to Entities)
So far I have written the following code which works.
var query = from Person in dbContext.Persons
join Phone in dbContext.Phones
on Person.PersonId equals Phone.PersonIdFK
where Person.PersonId=123
However, I'm unable to find a way to put a second condition on the "on" key word like this
on Person.PersonId equals Phone.PersonIdFK && Phone.IsActive == 1
Does Entity Framework even supports multiple conditions on a join?