Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the F# core libs be SQLCLR-approved?

Tags:

f#

sqlclr

According to this thread, F# Core must be SQLCLR-approved for assemblies to be marked SAFE. Is this planned? Can it even be done?

like image 918
Daniel Avatar asked Apr 14 '11 16:04

Daniel


People also ask

What happened to the show Kevin can f himself?

In November 2021, AMC confirmed the series would end after two seasons.

Is Patty Kevin's sister?

Allison and Kevin's neighbor, and Neil's sister, Patty (Mary Hollis Inboden) pops in from time to time. Although not exactly friends with Allison, she is the only one who tends to come to Allison's defense in this clear patriarchy.


2 Answers

I believe it can be done. However, F# core library is the sole property of Microsoft. This means you can't modify its code and recompile it to match and comply with SQLCLR SAFE. I suggest you add suggestion to Microsoft using Microsoft's connect website.

Microsoft connect is at: http://connect.microsoft.com (you have to register and have email account on live.com or hotmail.com before register).

To manually add your .NET DLL and integrate it to SQL Server, you can do this:

In this example, the DLL from your F# code has to be compiled first. I take this step from MSDN Library link: http://msdn.microsoft.com/en-us/library/ms254956(v=vs.80).aspx

Just don't forget to add PERMISSION_SET = SAFE to the CREATE ASSEMBLY command.

Here are the steps I quote from above link:

Loading and Running the "Hello World" Stored Procedure in SQL Server

Once the sample procedure has successfully compiled, you can test it in SQL Server. To do this, open SQL Server Management Studio and create a new query, connecting to a suitable test database (for example, the AdventureWorks sample database). We will need to create the assembly so we can access the stored procedure. For this example, we will assume that you have created the helloworld.dll assembly in the C:\ directory. Add the following Transact-SQL statement to your query.

CREATE ASSEMBLY helloworld from 'c:\helloworld.dll' WITH PERMISSION_SET = SAFE

Once the assembly has been created, we can now access our HelloWorld method by using the create procedure statement. We will call our stored procedure "hello":

CREATE PROCEDURE hello
AS
EXTERNAL NAME helloworld.HelloWorldProc.HelloWorld

Once the procedure has been created, it can be run just like a normal stored procedure written in Transact-SQL. Execute the following command:

EXEC hello

This should result in the following output in the SQL Server Management Studio messages window.

Hello world!

Edit: based on the commenter below, he's right about F# is now open source! You can modify and recompile it to suit your needs.

Edit: adding more detail guide on how to integrate the DLL to SQL Server CLR integration.

like image 76
Eriawan Kusumawardhono Avatar answered Oct 01 '22 06:10

Eriawan Kusumawardhono


A trick, as nasty as it is, would be using the --standalone flag of fsc (aka the F# compiler). This can even be added in the project settings and embeds in the output artifact the F# runtime library (along with all other dependencies deemed embeddable). I believe that at that point you should be able to do exactly what you want just by marking your assembly as SQLCLR safe.

like image 44
em70 Avatar answered Oct 01 '22 07:10

em70