TypeProvider query UNION case

Category:
TypeProviders.SqlDataConnection
Description: type provider sample: UNION. 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 TypeProvider12() =
let db = T0.GetDataContext();
let q = query {
for n in db.Student do
select (n.Name, n.Age)
}
let q2 = query {
for n in db.Student do
select (n.Name, n.Age)
}
let q3 = q.Union (q2)
q |> Seq.iter (fun n -> printfn "%A" n)
Assert.AreEqual(q |> Seq.length, 9)

Execution Result:
("Lisa", 21)
("Brent", 22)
("Anita", 20)
("Ken", 22)
("Cathy", 22)
("Tom", 20)
("Zeoy", 21)
("Mark", 23)
("John", null)
both elements are equal

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

Comments

No comments yet.