TypeProvider query LEFT JOIN case

Category:
TypeProviders.SqlDataConnection
Description: type provider sample: LEFT JOIN. Use the CreateFSharpSampleDatabase.sql to setup your database tables.
Code:

type T0 = Microsoft.FSharp.Data.TypeProviders.SqlDataConnection< "Data Source=localhost;Initial Catalog=FSharpSample;User ID=sa;Password=FSharpSample1234" >

let TypeProvider7() =
let db = T0.GetDataContext();
let q2 = query {
for n in db.Student do
join (for e in db.Course -> n.StudentID = e.CourseID)
select n
}

let q = query {
for n in q2.DefaultIfEmpty() do
select n
}
q |> Seq.iter (fun n -> printfn "%s" n.Name)
Assert.AreEqual(q |> Seq.length, 4)

Execution Result:
Lisa
Brent
Anita
Ken
both elements are equal

Last edited Mar 1, 2012 at 8:00 PM by ttliu2000, version 3

Comments

jkane Sep 21, 2011 at 6:44 PM 
This does not appear to be Left Join in the T-SQL sense. I would expect that a left join would give all 9 students, regardless of whether or not their StudentIDs matched a CourseID. This seems to be an Inner Join. If you delete query q and print and assert on q2, you get the same result.