Quantcast
Viewing all articles
Browse latest Browse all 25064

Loading a collection throigh the CSOM

Hello,

I have a method that loads all SharePoint groups through the .net  om in SharePoint 2013. When i load the group i just want to load some properties and my code looks something like this.

var siteGroups = ctx.Web.SiteGroups;
ctx.Load(siteGroups,
         lists => lists.Include(
                  list => list.Id,
                  list => list.Title,
                   list => list.Description,
                   list => list.Users.Include(u => u.Id,
                   u => u.Email,
                   u => u.LoginName,
                   u => u.Title)

                ctx.ExecuteQuery();

As you can see i'm also loading the users in my query and this gives me access to the user.count property. Now i want to skip loading the actuall users and just loiad the user count. When i try to change the code to this:

var siteGroups = ctx.Web.SiteGroups;
ctx.Load(siteGroups,
         lists => lists.Include(
                  list => list.Id,
                  list => list.Title,
                   list => list.Description,
                   list => list.Users.Count)

                ctx.ExecuteQuery();

The query fails telling me "The query expression 'list.Users.Count' is not supported."

How can i construct the query so that i get the user count without loading the actual users?


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>