I have a very normalized database, and I\'m trying to join two join tables together.
My goal is to only show documents that the user has permission to. I\'m using Ent
You can also view the SQL generated by EF 4.1 using either
Although, at this time, you need to use the LINQPad beta for EF 4.1.
Regarding your second question, I believe your query would translate fine. Using LINQPad to check the SQL, the following query
var a1 = Addresses.Where(a => a.City.ToUpper().EndsWith("L")).Select(a => a.AddressID);
var a2 = Addresses.Where(a => a.City.ToUpper().StartsWith("B")).Select(a => a.AddressID);
var x1 = a1.Intersect(a2);
translates to
SELECT
[Intersect1].[AddressID] AS [C1]
FROM (SELECT
[Extent1].[AddressID] AS [AddressID]
FROM [Person].[Address] AS [Extent1]
WHERE UPPER([Extent1].[City]) LIKE N'%L'
INTERSECT
SELECT
[Extent2].[AddressID] AS [AddressID]
FROM [Person].[Address] AS [Extent2]
WHERE UPPER([Extent2].[City]) LIKE N'B%') AS [Intersect1]
I think @Slauma's recommendation to use navigation proeprties is the way to go if your model supports it.
Still, get LINQPad - you won't regret it :)