Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1870
  • Last Modified:

CAML query to groupby does not work to get sharepoint list

I have a SP list that I am trying to retrieve in my silvelight project.
Please note that I am using the Microsoft.Sharepoint.Client.Silverlight dll

I have a SP List called Region, which has a few columns. I am trying to get a distinct set of data from the list

Here is my code


ListItemCollection allRegions;
SP.List oList = oWebsite.Lists.GetByTitle("Region");              
               
                CamlQuery camlQuery = new CamlQuery();
                              camlQuery.ViewXml = "<View><GroupBy><FieldRef Name='Location_x0020__x0020_'/></GroupBy></View>";

clientContext.Load(allRegions,
                    items => items.Include(
                         item => item["Location_x0020__x0020_"] )
                         )
                                         
                      );
0
countrymeister
Asked:
countrymeister
  • 2
1 Solution
 
Jamie McAllister MVPSharePoint ConsultantCommented:
Group By only works if you also sort. Also you *may* not need the View elements.
0
 
countrymeisterAuthor Commented:
You do need the view statement especially if you have a where clause and a group by clause.
Also there is no need for sort when grouping

Let me know if you need a code sample.
0
 
countrymeisterAuthor Commented:
I resolved this myself
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now