This project is read-only.
TypeProvider query GroupBy case

Category:
TypeProviders.SqlDataConnection
Description: type provider sample using GroupBy. 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 TypeProvider4() =
let db = T0.GetDataContext();
let q = query {
for n in db.Student do
groupBy n.Age into g
where (g.Key.HasValue && g.Key.Value > 1)
select (g.Key, g.Count())
}
q |> Seq.iter (fun n -> printfn "%A" n)
Assert.AreEqual(q |> Seq.length, 4)

Execution Result:
(20, 2)
(21, 2)
(22, 3)
(23, 1)
both elements are equal

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

Comments

No comments yet.