I have two tables (clients and emails), one with customer's data, including a main email address, and another one with additional email addresses.
I need to validate the user from one of their many email addresses, no matter if it is on clients or emails table. I've come up with this SQL sentence which works fine:
set @email = 'client@domain.com';
select c1.credits > 0 as Allowed, c1.Email as MainEmail from
customers c1 inner join (select ClientId, Email FROM customers WHERE
Email=@email union all select ClientId, Email FROM emails WHERE Email=@email) e1
on c1.ClientId = e1.ClientId;
How to write this query in LINQ to Entities with method-based syntax?