我使用SqlEntityConnection(实体数据模型)TypeProvider连接到具有几个表和存储过程的SQL Server数据库。
#if INTERACTIVE
#r "System.Data"
#r "System.Data.Entity"
#r "FSharp.Data.TypeProviders"
#endif
open System.Data
open System.Data.Entity
open Microsoft.FSharp.Data.TypeProviders
// You can use Server Explorer to build your ConnectionString.
type internal SqlConnection = Microsoft.FSharp.Data.TypeProviders.SqlEntityConnection<ConnectionString = @"DataSource=server etc">
let internal db = SqlConnection.GetDataContext()
根据模板文件中的链接提供的文档 - http://go.microsoft.com/fwlink/?LinkId=229210 “获取数据上下文,这是一个包含数据库表作为属性的对象,数据库存储过程和函数作为方法。” db应该将数据库中的存储过程作为方法。但是,我只能将数据库中的表视为db的属性。 我错过了什么?
答案 0 :(得分:4)
我认为文档不正确。 SqlEntityConnection
TP使用后端中的工具edmgen.exe
来执行实际的代码生成和繁重的工作,并且据我所知,该工具不支持将存储过程作为生成的代理类的一部分包括在内。 Here's another SO question正好询问这一点,遗憾的是没有回复。
正在运行
edmgen.exe /mode:FullGeneration /connectionstring:"..." /language:CSharp /p:EdmTest
输出各种文件,其中只有一个(.ssdl
文件)包含有关我的数据库中存在的存储过程的任何信息。
SqlDataConnection
TP肯定 支持存储过程,以防您可能选择。