How To: Using SPMetal Utility in SharePoint 2010 to “presumably” manipulate data on a BCS External List 5


So this blog started out with me trying to prove that can use LINQ to SharePoint via the SPMetal Utility in SharePoint 2010 to gain access to Business Connectivity Services (BCS) External Content Types // External Lists. In plain English, I wanted to use LINQ to SharePoint in as little code as possible and without using the BCS Template to do CRUD actions to External Lists created in SharePoint. I found out out that I was unable to using SharePoint 2010 BETA and Visual Studio 2010 Beta 2… basically SPMetal did not create the necessary Entity Classes for External Lists in the resultant C# file.

Therefore, I will turn this blog into a How-To for using the SPMetal Utility and point you to Serge Luca Blog for some great Web Cast on just how to use LINQ to SharePoint to access Lists in SharePoint 2010!

So the first thing you can do is bone up on SPMetal. You can read up on it at or BING “SPMetal SharePoint”


Next I picked a SharePoint 2010 Site that had few clutter and still had List Created OOB that I could play with.


I settled on my “Charlie” Site


Next, I added an External Content Type to create an External List called “A Few People I Know” which resulted in the two screen shots below…



Then just to make sure I do my due diligence, I created two Custom Lists

  • One List that will do lookups to my external List but remains a custom list
  • One List that will just be a custom list with regular columns


So in my list called “Regular People I know List” I am doing lookups to my External Lists Data…


My Resulting List looks like below…


Then I created my RegularPeopleNOLookup List which is just a vanilla list with stuff in it.


Now Time for the FUN! Stuff, we get to crack open Visual Studio 2010 Beta 2 and Code Away!

Steps I took that led be to below..

  • Created a Console Application
  • Set the Build Type Platform to “Any CPU” since i am on a x64 bit system
  • Add References to
    • Microsoft.SharePoint
    • Microsoft.SharePoint.Linq


Next I will use SPMetal to create located in the “BIN” folder under the “14-Hive”, is that what we are calling it… I cant remember, but I know we were given the nomenclature in Vegas! :-)


The syntax for the utility against my Charlie Site is below..


At this time now as you can see in my working folder, I have a file created called “CharlieSiteLists.cs” which is where the Entity Classes are located for the Lists in the “Charlie” site… My HOPE is/was that I will get my External List showing up too.. bummer it didn’t…

Below you have the “CharlieSiteListDataContext” which is basically your wrapper to the Content Database through LINQ





Below you can see the Entity Classes representative of the SharePoint List in the “Charlie” Site.




What helps us out here is that the Entity List Class implements IQueryable and IEnumerable which will help us out in our LINQ operations.


So here is where I will bail out…since I wasn’t able to get to my SharePoint –> Business Connectivity Services –> External Content Type –> External List that I created in my Lab. So Just to show you how it LINQ to SharePoint works see below how I add a data element to my List… MUCH better examples and walkthru are available on Serge Luca’s Blog.



Have Fun with That! Hopefully the story changes with External List when RTM comes out… that’d be really cool.

Leave a comment

Your email address will not be published. Required fields are marked *

5 thoughts on “How To: Using SPMetal Utility in SharePoint 2010 to “presumably” manipulate data on a BCS External List

  • Richard Reukema

    I was hoping that external lists would be accessible as well. Did you hear or find out anything more in regard to this functionality? Being new to SharePoint, I figured that once the external content type was created, it would be listed along all the other content types – like an ODBC abtracts away the actual persistance engine (SQL, Excel, etc.).

    Where in SharePoint do they list “external content types” other than “Manage Service Applications”.

    If you could point me to any documentation, it would be greatly appreciated.


    • fabiangwilliams

      I pinged Serge Luca on that but he said there was no capability to do that in the current builds.. not sure if RTM will give us that option, but i will take this opportunity to go bug Serge agian…

  • Richard Reukema

    What would be interesting is just how and why the external types are treated separately from the current content types. This just might be my level of knowledge, but I don’t see why they would be treated differently when we put in all the entity model information to layover the class doing the actual work. Like I said, I would have thought this would abstracted where the content type was getting it’s data, and what operations were defined. In my line of thinking, there should be no difference.