user1256789
user1256789

Reputation: 131

Compare two lists in SharePoint 2010

I am working on SharePoint 2010 and need to compare two sites. The comparison has to include the lists within those sites. I need to know if there is anything that I should compare apart from the content of the lists? Also, what would be the best way to compare two lists?

Upvotes: 2

Views: 2438

Answers (1)

Kyle Trauberman
Kyle Trauberman

Reputation: 25694

This is a basic example, you'll probably do something a little more complex, especially if you're wanting to use a custom CamlQuery to filter the items, or check the settings of the list.

using(ClientContext ctx = new ClientContext("http://url.to.site.com/"))
{
    Web web = ctx.Web;
    List list = web.Lists.GetByTitle("Pages");
    ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());

    ctx.Load(list);
    ctx.Load(items);

    ctx.ExecuteQuery();

    // after the ExecuteQuery call, list and items will contain references
    // to the lists and the items in the list.
}

Make sure you reference Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll. These can be found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI on one of the SharePoint servers in the farm. Copy them to your project and reference them.

For more information on the client object model, I recommend checking out this article: http://msdn.microsoft.com/en-us/library/ee857094.aspx

Upvotes: 2

Related Questions