Olaf and I were cracking away on some SharePoint 2010 work which we thought should
be simplepoint SPMetal to the site and start LINQ-ing to our hearts content..

with the one exception that we couldn’t select items from a list based on their Content

By default SPMetal.exe doesn’t include these ’system’ fields (apart
from ID + Title – go figure) and the secret is to use an Override file.

The good oil is:http://msdn.microsoft.com/en-us/library/ee535056.aspx

(Here’s a good article on how .NET Types are mapped to SharePoint – http://msdn.microsoft.com/en-us/library/ee536245.aspx)

The simple override/parameters file:

<Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">

  <ContentType Name="Item" Class="Item">
    <Column Name="ContentType" Member="ContentType" />


The SPMetal Command Line

The VS.NET Code

 static void Main(string[]
            using (BreezeDataContext dc = new BreezeDataContext("http://breezelocal"))
                var myitems = from i in dc.GetList<ContentListTraining>("My Content List")
                              where i.ContentType == "Training"
                              select i;
                var courses = myitems.ToList<ContentListTraining>();

                Console.WriteLine("There are {0} items",courses[0].Title);