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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s