Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

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_"] )
                         )
                                         
                      );
Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

Group By only works if you also sort. Also you *may* not need the View elements.
ASKER CERTIFIED SOLUTION
Avatar of countrymeister
countrymeister

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of countrymeister
countrymeister

ASKER

I resolved this myself