我正在使用 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 的属性。 我错过了什么?
最佳答案
我认为文档不正确。 SqlEntityConnection
TP 在后端使用工具 edmgen.exe
来执行实际的代码生成和繁重的工作,据我所知,该工具不支持包括存储过程作为生成的代理类的一部分。 Here's another SO question正是在询问这个问题,遗憾的是没有回复。
运行
edmgen.exe /mode:FullGeneration /connectionstring:"..." /language:CSharp /p:EdmTest
输出各种文件,其中只有一个(.ssdl
文件)包含有关我的数据库中存在的存储过程的任何信息。
SqlDataConnection
TP 绝对确实支持存储过程,以防您有可能选择它。
关于f# - SqlEntityConnection(实体数据模型)TypeProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17894670/