0

I have a List that holds the URLs of the Subsites I want to retrieve. I need to use that as a filter (optimize the query) so when I query the SharePoint it only returns the webs I want to work with. I'm using CSOM and I was trying this query:

    List<string> listOfSites = new List<string>(); // lets consider this has been populated

    var query = from webs in subsites
                where listOfSites.Contains(webs.Url)
                select webs;

   IEnumerable<Web> webz = clientContext.loadQuery(query);

I can't use Contains, ClientContext throws an exception when I try to use it. Do I have any alternative?

  • What are you trying to achieve, there might be another way rather getting all webs like this. – Amal Hashim Nov 18 '14 at 15:49
  • I just don't want to get all webs when I know exactly in what webs I will work on. Basically I'll delete all webs whose URLs are contained on that List. – Fabio Nov 18 '14 at 16:07
  • If you have the list of URL's then you can do a foreach and delete those. I think that is the best option. – Amal Hashim Nov 18 '14 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.