basquang™ on clouds

May 28, 2009

LINQ to SharePoint: now available from Microsoft!

Filed under: LINQ — basquang @ 11:38 AM

I’ve waiting for “LINQ to SharePoint” feature from Microsoft a long time. Now, with SharePoint SP2 and VS 2008, We’ll easy to use LINQ feature to query SharePoint data.

Before, I tried to use “LINQ for SharePoint” from CodePlex, but I didn’t happy. I think the support from Microsoft for LINQ to SharePoint is the best.

Thanks for the improvement. I’m waiting for some improve features in next version of SharePoint, maybe SharePoint 2010.

Here are my code using LINQ with SharePoint data

SPSite site = new SPSite("http://basquang:8001");
SPWeb web = site.RootWeb;
var listItems = from SPListItem item in web.Lists["Tasks"].Items
                where DateTime.Parse(item["Due Date"].ToString()) <= DateTime.Today
                select item;
foreach (var item in listItems)
{
    Console.WriteLine(item.Title);
}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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

Create a free website or blog at WordPress.com.

%d bloggers like this: