Google-sovellukset
Päävalikko

Post a Comment On: mo.notono.us

"Beware of SPList.Items.Add()"

2 Comments -

1 – 2 of 2
Blogger Prashant said...

Great find! I think your optimized method could be pretty useful to add items to a big list.

I hope they fix this in Sharepoint 2010.

Tuesday, September 22, 2009 2:01:00 AM

Blogger Oskar Austegard said...

SharePoint 2010 addresses this through adding an AddItem method for the SPList class. Internally it uses the static SPQuery.TrivialQuery (essentially an empty query*) to add the item to an empty ListItem collection, achieving the same effect as AddItemOptimized():

*TrivialQuery code:

internal static SPQuery TrivialQuery
{
get
{
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name=\"ID\"/><Value Type=\"Integer\">-1</Value></Eq></Where>";
query.ViewFields = "<FieldRef Name=\"ID\"/>";
return query;
}
}

Monday, July 19, 2010 3:43:00 PM

You can use some HTML tags, such as <b>, <i>, <a>

Comments on this blog are restricted to team members.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot