Solved

CAML query to groupby does not work to get sharepoint list

Posted on 2012-04-10
3
1,343 Views
Last Modified: 2012-06-12
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
Comment
Question by:countrymeister
  • 2
3 Comments
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 37829129
Group By only works if you also sort. Also you *may* not need the View elements.
0
 
LVL 1

Accepted Solution

by:
countrymeister earned 0 total points
ID: 37932836
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
 
LVL 1

Author Closing Comment

by:countrymeister
ID: 38073262
I resolved this myself
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question