TypeProvider query GroupBy and OrderBy DESC case

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

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

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

Comments

No comments yet.