Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

What's a good way to perform an Exists or Count on the client object model classes?

I have list with views. I want to check if a view already exists before creating it. Tried a couple of things, but the only thing which actually seems to work is loading the entire collection and using a foreach to check each views' title. I was hoping for a neater way using Linq for instance.

Tried:

  • Performing a Where on the ViewCollection and loading that with LoadQuery. But when you perform Count() on that collection, you get an error.
  • performing a Load on the entire Views collection and querying that; again an error.
  • performing a count and loading the result, seems to be unsupported
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You could try using the ViewCollection.GetByTitle or List.GetView method to fetch the already existing view. If the view is present, it will be returned and you wont need to create the new view.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.