Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1738
  • 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 MVPArchitectCommented:
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

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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