Thứ Năm, 28 tháng 5, 2009

Using LINQ with SharePoint 2007 Objects

 

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

 

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

Không có nhận xét nào:

Đăng nhận xét