Solved

CAML query to groupby does not work to get sharepoint list

Posted on 2012-04-10
3
1,257 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
Comment Utility
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
Comment Utility
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
Comment Utility
I resolved this myself
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now