Accessing Lists through Sharepoint Object model

Is accessing the list taking more time…

Consider the following while accessing the list  through Object model

  1. SPWeb.GetList(string url)
    In this case, first it gets the list GUID from the url(database hit), then it loads the Meta data for that specific list.
  2. SPWeb.Lists[“name”]
    This method loads the meta-data information of the all lists for the SPWeb object under consideration. and then it does SPList.Title comparison with metadata of all the lists returned and returns the first matching list from the SPWeb.Lists collection.

The first approach provides better performance than the second one.

If we pass GUID of the list  instead of a list name in the second approach it works similar to the first approach (SPWeb.GetList (url)), however passing a List Index would work similar to the second approach.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

Hmm… I read blogs on a similar topic, but i never visited your blog. I added it to favorites and i’ll be your constant reader.

I added your blog to bookmarks. And i’ll read your articles more often!

Leave a comment

(required)

(required)