2014-10-02 37 views
2

我有一个查询值或构造查询没有定义

query { 
    for user in db.Users do 
    join (for selection in db.CourseSelection -> 
      user.UserID = selection.UserID) 
    select (user, selection) 
} 
|> Seq.iter (fun (user, selection) -> printfn "%d %s %d" user.UserID user.Name selection.GroupID) 

为什么它说:“没有定义的值或构造‘查询’”?

我已经实现了LINQ的图书馆

open System 
open System.Linq 

或是否有更好的方式来做到这一点在内建的方法? 像内置查询表达式一样吗?

回答

2

这里是F#查询表达式的文档和教程: http://msdn.microsoft.com/en-us/library/vstudio/hh225374(v=vs.110).aspx

据指出,“项目应添加引用System.Data,System.Data.Linq程序,并FSharp.Data.TypeProviders组件。”

open Microsoft.FSharp.Data.TypeProviders 
open System.Data.Linq.SqlClient 
open System.Linq 
open Microsoft.FSharp.Linq 

样品它指这些命名空间中