TypeProvider query DISTINCT case

Category:
TypeProviders.SqlDataConnection
Description: type provider sample: DISTINCT. 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 TypeProvider9() =
let db = T0.GetDataContext();
let q = query {
for n in db.Student do
join (for e in db.CourseSelection -> n.StudentID = e.StudentID)
distinct
}
q |> Seq.iter (fun (s, c) -> printfn "(Name=%s, CourseID=%d)" s.Name c.CourseID.Value)
Assert.AreEqual(q |> Seq.length, 6)

Execution Result:
(Name=Lisa, CourseID=1)
(Name=Brent, CourseID=1)
(Name=Brent, CourseID=2)
(Name=Anita, CourseID=1)
(Name=Anita, CourseID=2)
(Name=Anita, CourseID=3)
both elements are equal

Last edited Mar 1, 2012 at 7:01 PM by ttliu2000, version 2

Comments

No comments yet.