我正在寻找一个关于使用F#查询实体数据源的示例或教程.
老实说,我没有找到太多.你们有没有运气好吗?
以下是我能够根据我在此博客上找到的内容拼凑而成的示例
open Microsoft.FSharp.Linq.QuotationEvaluation open Microsoft.FSharp.Linq let IsPermited (serviceName:string) = //Instantiate the Entity let data = new BusModelContainer() //Build your query let services = Query.query <@ seq{ for service in data.ServiceSet do service.Name.Equals(serviceName) && service.IsEnabled then yield service } @> if Seq.is_empty services then false else true
以下是博客中的代码,向我展示了如何从实体中进行选择
let db = new FSharpSampleDB(connString) Query.query <@ seq { for c in db.Customers do if id = c.CustomerId then yield (new Customer(c.CustomerId, c.Name, c.Balance))} |> Seq.hd @> :> ICustomer