Thursday, June 25, 2009

Check if SPList or SPView exists

One thing that the SharePoint team left out is a built-in way to see if a SPList or SPView exists.

So if you have the Dynamic library from ScottGu's Blog then you can setup an extension method or helper method with the following linq:

SPList

spweb.Lists.Cast().Any(list => string.Equals(list.Title, listName));

SPView

splist.Views.Cast().Any(view => string.Equals(view.Title, viewName));

both return a boolean

No comments:

Post a Comment