0

After running SPMETAL.exe against my Sharepoint 2016 site, I imported the generated model to my project. I get 263 errors of the type "The type or namespace name 'Linq' does not exist in the namespace 'Microsoft.Sharepoint' (are you missing an assembly reference?).

By the way, in order to generate a datacontext model from your Sharepoint site for use with Linq to SQL with SPMETAL.exe, here's the command: "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\BIN\SPMETAL.exe" /web: /namespace: /code: Change the "16" above, depending on the version of Sharepoint you have / which folder you have there.

I have already referenced Microsoft.SharePoint.dll and installed the client and client runtime using Nuget.

Did something major change and can I still use SPMETAL? I've done a ton of searches, but other namespaces with Linq show up and I still haven't found what assembly or package Microsoft.Sharepoint.Linq resides in.

JakeJ
  • 2,361
  • 5
  • 23
  • 35
  • All the results for Microsoft.Sharepoint.Linq extend through Sharepoint 2013. I wonder what exactly changed with the namespaces? I know they wouldn't get rid of Linq completely. – JakeJ Dec 15 '17 at 17:24
  • Also, I have a Sharepoint installation on another machine on my network. I am querying that. I've already queried it using the CSOM. I've read that SPMETAL is supposed to still work with on-premise Sharepoint. – JakeJ Dec 15 '17 at 19:14

1 Answers1

0

After Googling quite a bit, I found a reference to the assembly the Microsoft.Sharepoint.Linq namespace is located within: "Microsoft.Sharepoint.Linq.dll". I did a file search for that and found it in the .NET install, assemblies subfolder: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Linq\v4.0_16.0.0.0__71e9bce111e9429c\

I included a reference to that in my project and all the errors went away.

JakeJ
  • 2,361
  • 5
  • 23
  • 35
  • It's also worth noting that the dlls are only located on machines with Sharepoint installed. I copied it to the other machine in order to be able to access Linq to Sharepoint in my project. – JakeJ Dec 15 '17 at 19:39