您的位置:首页 > 其它

处理 GroupBy 和 OrderBy DESC

2012-02-25 17:46 239 查看
处理 GroupBy 和 OrderBy DESC

#r @"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Linq.dll";;

#r @"E:\Projects\F#3\FSharp.Data.TypeProviders.dll";;

open Microsoft.FSharp.Data.TypeProviders;;

open System.Linq;;

// Count() 在其中

[<Generate>]

type T0 = SqlDataConnection<"Data Source=.\SQLEXPRESS;Initial Catalog=FSharpSample;User ID=sa;Password=FSharpSample1234">

let TypeProvider4() =

let db = T0.GetDataContext()

let q = query {

for s in db.Student do

groupBy s.Age into g

where ( g.Count() > 1 )

sortByDescending ( g.Count() )

select ( g.Key, g.Count() )

}

q |> Seq.iter (fun n -> printfn "%A" n)

q |> Seq.length
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐