0

We are beginning to use VS2012 for our solution. One of the projects is SQL CLR. When I try to compile it, I get the following error:

CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

However, the same code compiles fine in VS2010. The project has a reference to the System.dll. What could be going on? Thanks.

laconicdev
  • 6,360
  • 11
  • 63
  • 89
  • The error says it all: you need to add a reference to the Linq assembly(s). – RBarryYoung Aug 15 '12 at 17:19
  • Why does the exact same project work fine in VS2010? Did MS change something on Linq and references? – laconicdev Aug 15 '12 at 17:42
  • Not sure, but I would suspect a difference in the default assembly reference list. Are you trying to upgrade the project, or are you just creating a new project and copying the old code into it? – RBarryYoung Aug 15 '12 at 17:49
  • Hmmm. Well that's odder, as it should carry-over the original assembly reference list. I'd suggest comparing the original assembly reference list to your current one to see if anything was changed by the Upgrade. – RBarryYoung Aug 15 '12 at 18:24
  • It could be it is still pointing at the 2010 version of the assembly reference, which probably has the exact same name as the 2012 reference. You may need to manually remove the reference to the 2010 version and add the 2012 version. – Andrew Clear Aug 15 '12 at 21:17

1 Answers1

2

Please refer to:

You need to add a reference to System.Core.dll (Use .NET 3.5 for MS-SQL 2008):

// ...    
using System.Linq;

    public partial class StoredProcedures
    {
        [SqlProcedure]
        public static void MyProcedure()
        {
            // ...
            List<string> list = new List<string>();
            var result = list.Where(x => x == "string");
            // ...
        }
    }
Gonzalo Contento
  • 857
  • 9
  • 21