tags:

views:

572

answers:

3

I would like to know the best Practice that you guys follow when it comes to access the SharePoint List Items / Doc Lib using Object Model. To start let me share few things I have found.

  1. Limit the number of Items Per container to 2K items.
  2. Use ProcessWebData method of SPWeb to do Update/Insert of Large items
+1  A: 

To completely answer your question would require a full blog post. There are several of these out there on the IntraWebs already.

Here are a few of the major points:

  • Avoid iterating though the entire list unless you need to see every item
  • If you do iterate through the list, use a foreach loop instead of a for loop
  • In all other cases use an SPQuery or an SPSiteData query

  • Access columns by the internal name or the field ID

Rob Windsor
One example is http://www.sharepointdevwiki.com/display/public/Accessing+List+Items+using+SPList+using+the+object+model but it's incomplete regarding performance.
Alex Angas
A: 

You should also take a look at Common Coding Issues When Using the SharePoint Object Model as it has some examples on how to avoid serious performance problems.

Janis Veinbergs
A: 

If you are using the SharePoint 2010 then I prefer to use Client Object Model instead of server client object model because of lots of advantages. So, Using Client OM call the sharePoint 2010 server and access the list and from it access the list item by id or url or SPQuery.

Let me mknow, if you need any help.

Rare Solutions