Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using System.Linq assembly in SQL CLR UDF

I am creating a SQL Server user-defined function in C# using the SQL UDF project type in Visual Studio 2010. I have a simple Linq string manipulation expression (myString.Where()) in my code that generates an error because I'm not using the System.Linq namespace. If I add

using System.Linq;

to my .cs file, I get an error asking me if I'm missing an assembly reference. If I then right-click the project in Solution Explorer, and select "Add Reference", there is no System.Linq component listed in the .NET tab.

I suppose I could go browsing the hard drive for the appropriate assembly DLL, but why doesn't Visual Studio know about it? Is there some restriction about using Linq in SQL CLR code?

like image 925
Buggieboy Avatar asked Oct 23 '13 18:10

Buggieboy


1 Answers

Okay, apparently adding a reference to System.Core.DLL to the project will allow the "using System.Linq" statement to compile in a SQL CLR project. Go figure.

like image 130
Buggieboy Avatar answered Nov 16 '22 05:11

Buggieboy