SharePoint 2010 cumulative updates

SharePoint 2010 cumulative updates

This table summarises the know SharePoint 2010 cumulative updates.

Release Date Microsoft SharePoint Foundation 2010 Microsoft SharePoint Server 2010 Version
August 2012 KB2687355 KB2687353 14.0.6126.5000
April 2012 KB2598321 KB2598151 14.0.6120.5000
October 2011 KB2596508 KB2596505 14.0.6112.5000
June 2011 KB2536601 KB2536599 14.0.6106.5000
April 2011 KB2510639 KB2510639 14.0.5136.5002
Service Pack 1 (SP1) KB2460058 KB2460045
August 2010 KB2266423 KB2276339 14.0.5123.5000
June 2010 KB2028568 KB983319KB983497KB2281364KB2124512KB2182938

(Japanese only)

How to simulate the SQL WHERE IN clause in a SPQuery

Simulate a WHERE IN clause in a SPQuery

If you ever have used something like

SELECT * FROM table WHERE field IN ('value1','value2','value3','value4')

 

in T-SQL, and wanted to mimic this functionality in the SharePoint SPQuery class, you probably have found out there is no IN statement in the CAML Query language.
So what do do? Here’s a way to simulate WHERE IN clause in a SPQuery statement.

One solution is to use a LinQ query that looks something like this:

var values = new List {"value1", "value2", "value3"};
var listItems = from SPListItem tItem in list.Items
orderby tItem.Title ascending
where values.Contains(tItem["Title"].ToString())
select tItem;
foreach (var spListItem in listItems)
{
Console.WriteLine(spListItem.Title);
}

However, this has a serious performance problem. Because the .AllItems property will do a full T-SQL select all items behind the scenes, it can get very slow if you have thousands and thousand of items in your list.
It do look elegant, however.

Another way is to build up a CAML query that does an OR statement for every item that you have in your list of values.
Essentially, you will have to build up something that looks similar to this CAML query:

value1

value2

value3

 

Notice that the CAML syntax for multiple OR statements is a little bit odd. You would at first glance think that is would look like this:

value1

value2

value3

But this will throw an error. You will need to have nest the OR statements within each other.

For this purpose I have written a small helper method that will build the CAML query for a given list of values in a List of strings.
You call it like this:

SPQuery query = new SPQuery();
query.RowLimit = 2000;
query.ViewFields = "";
var whereClause = GetWhereClause("Title", "Eq", new List
{
"value1", "value2", "value3"
});
query.Query = string.Format(@"{0}", whereClause);
// Get the list items
SPListItemCollection items = list.GetItems(query);

The first parameter is the field that you want to comapre on, the second parameter is the type (“Eq” makes most sense in this scenario), and the third parameter is of List of strings.
Here’s the code for the helper method:

private static string GetWhereClause(string fieldName, string whereElement, IEnumerable list)
{
var sb = new StringBuilder();
var makeFirstEntry = true;
foreach (var entry in list)
{
var savedQuery = sb.ToString();
sb = new StringBuilder();
if (!makeFirstEntry)
{
sb.Append("");
sb.Append(savedQuery);
}
else
{
sb.Append(MakeStatement(whereElement, fieldName, entry));
makeFirstEntry = false;
continue;
}
sb.Append(MakeStatement(whereElement, fieldName, entry));
sb.Append("");
}
return sb.ToString();
}
private static string MakeStatement(string whereElement, string fieldName, string entry)
{
var sb = new StringBuilder();
sb.Append(string.Format("<{0}>", whereElement));
sb.Append(string.Format("{1}", fieldName, entry));
sb.Append(string.Format("", whereElement));
return sb.ToString();
}