Using LINQ with SharePoint


As Beta II TR is working on .NET 3.0 which has LINQ feature.  LINQ is used for language integrated query.  There are many tuturils available to learn LINQ so try google for that.  Just for the information if i need to traverse throught SharePoint sites.  The code would be like this

SPSite site = new SPSite("http://server/site");
SPWeb web = site.AllWebs[0];

SPList> hiddenLists = new SPlist(); // Do not use an SPListCollection here
foreach (SPList list in web.Lists)
{
    if (list.Hidden)
        hiddenLists.Add(list);
}

in LINQ it will look like this

var hiddenLists = from list in web.Lists where list.Hidden select list

Isn’t Great !!!!

Learn More Click here