Sunday, June 12, 2016

.Net Client side managed code sample

Below examples shows retrieving list data using console application by .Net managed code implementation. Code uses SharePoint.Client.dll and SharePoint.Client.Runtime.dll as reference.

[code]using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new ClientContext("http://sharepoint2013.gcm.com/sites/RBSSharePoint/"))
            {
              var web =context.Web;
              var query = from list in web.Lists
                          where list.Hidden == true && list.ItemCount > 0
                          select list;
              var lists = context.LoadQuery(query);     
              context.ExecuteQuery();
              Console.WriteLine(lists.Count());       
          Console.ReadLine();
            }
        }
    }
}[/code]

No comments:

Post a Comment