我应该在 SqlClr 中运行 F# 吗?

发布于 2024-10-22 23:17:29 字数 726 浏览 1 评论 0原文

我需要在 Sql 中运行 .Net 代码,并且我试图在 F# 和 C# 之间做出决定。 现在我用 F# 编写的代码越来越多,所以如果不是太不切实际,我希望它是 F#。

是否可以强制 VS2010 将我的 F# 程序集(及其引用)部署到 Sql Server,就像 C# 项目一样?

您会推荐/不推荐在 Sql 中运行 F# 吗?为什么?

编辑: 我同意语言更好,这不是问题。我主要想知道是否有人有在 SqlClr 中使用 F# 的经验,特别是这些工具是否可以提供简单的开发工作流程,即在 VS2010 中部署。

编辑2: 我正在尝试这个,手动注册非常痛苦。除了CREATE ASSEMBLY之外,您还必须注册每个函数、sp、聚合等。您还必须首先以正确的顺序删除它们(如果存在),以免您因为'而DROP ASSEMBLY失败。 Nibbler' 由对象“Hello”引用。

然后,我想到使用 C# 项目作为前端,并让该项目引用 F# 项目,以便自动处理所有这些部署。事实证明,您只能引用其他 C#/VB Sql Clr 项目,或者已在 Sql 中引用的程序集。不过,这仍然可以简化部署,因为所有功能的创建/删除等都将自动处理。然后,为了从测试部署到生产,我只需从测试环境中注册的所有内容生成脚本。

附言。我还尝试摆弄 .fsproj 文件,与 C# Clr 项目的 .csproj 进行比较,以启用部署但无济于事。

I need to run .Net code in Sql and I'm trying to decide between F# and C#.
I'm doing more and more code in F# nowadays so if it's not too impractical, I'd like it to be F#.

Is it possible to coerce VS2010 to deploy my F# assemblies (and their references) to Sql Server, in the same nice way a C# project does?

Would you recommend/not recommend running F# in Sql? Why?

EDIT:
I agree that the language is better, that is not the question. I was mainly wondering if anyone had experience with using F# in SqlClr and specifically if the tools can offer a simple workflow for development, i.e. Deploy in VS2010.

EDIT 2:
I'm experimenting with this, and registering manually is downright painful. Besides CREATE ASSEMBLY you have to register each function, sp, aggregate etc. You also have to drop them in the right order first, if they exist, lest you get a DROP ASSEMBLY failed because 'Nibbler' is referenced by object 'Hello'.

I then had the idea to use a C# project as a front end and have this project reference an F# project, just to have all this deploying taken care of automatically. Turns out you can only reference other C#/VB Sql Clr projects, or assemblies that are already referenced in Sql. This could still simplify deployment though, as all creation/deletion of functions etc would be handled automatically. Then, for deploying from test to production, I would just generate scripts from all the stuff that is registered in my test environment.

PS. I also tried fiddling with the .fsproj file, diffing with the .csproj of a C# Clr project, to enable deployment to no avail.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听闻余生 2024-10-29 23:17:29

如果您在 SQL CLR 上下文中使用 FSharp.Core 和其他引用时遇到问题,您可以尝试 --standalone 编译器标志,用于将外部引用嵌入到部署到 SQL Server 的程序集中。

If you have trouble with FSharp.Core and other references in the SQL CLR context, you could try the --standalone compiler flag to cause external references to be embedded in the assembly that you deploy to SQL Server.

萌化 2024-10-29 23:17:29

我建议使用 F# 编写 CLR UDF/过程,其原因与我建议使用 F# 编写几乎任何内容的原因大致相同(请参阅 SO 上的众多 F# 与 C# 问题)。我想不出有什么理由偏爱 C#。任何事情。我还没有尝试使用 VS 将程序集部署到 SQL Server,但是 CREATE ASSEMBLY 工作得很好......并且无论编程语言如何,工作原理都是一样的。

I would recommend coding your CLR UDFs/procedures in F# for much the same reason I'd recommend coding almost anything in F# (see the numerous F# vs C# questions on SO). I can't think of a reason to prefer C# for anything. I haven't tried deploying assemblies to SQL Server using VS, but CREATE ASSEMBLY works just fine...and works the same, regardless of programming language.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文