When I create a list in SharePoint and want to run LINQ agaisnt it I use SPMetal to auto generate the mapping.

SPMetal.exe /web:http://mysite /code:C:\MyFile.cs

This does not seem to generate the bindings for extenal lists. How could I generate the bindings?

Would I be better off not using LINQ and using the SharePoint Object Model ( http://www.zimmergren.net/archive/2010/01/19/sp-2010-programmatically-work-with-external-lists-bcs-in-sharepoint-2010.aspx )

2 Answers 2


LINQ to SharePoint spmetal.exe does not support external lists http://nileshmandekar.blogspot.com/2011/04/limitations-of-external-list-using-bcs.html

But there is an article how to make it work: http://fabiangwilliams.wordpress.com/2010/01/03/how-to-using-spmetal-utility-in-sharepoint-2010-to-presumably-manipulate-data-on-a-bcs-external-list/

I suggest to use SharePoint Object Model as a more tested & recommended API for working with External Lists


If the objective is just to query lists using LINQ and you can directly do that without SPMetal. LINQ can be directly used on SPListItemCollection e.g.

SPlist CustomerList = Web.TryGetList("Customers");  
var FindCustomer = from SPListItem Item in CustomersList.Items
                   where Item["Orders"] as int == 5
                    select Item;

//or select new{Title = Item["Title"]}

This does not have hard coded entities but is more flexible. And as long as your list column names remain same, code can be deployed on any environment without recompiling (even if other lists are changed). Also you can choose to retrieve few chosen field's data instead of retrieving data of all the fields every time.

  • Thus you get all items from list (Items property) and do a query in memory (Linq to Objects), in case of many items it will decrease performance. Dec 20, 2011 at 11:07
  • I glad you posted about the performance. It is not great at all. I have a big BCS list 1,000,000 items so it is not fast. Will try CAML way to see if that improves things. If not I may skip a SharePoint list completley.
    – John
    Dec 20, 2011 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.