0

I have tried the following in CAML but it does not seem to be returning them sorted

 SPQuery query = new SPQuery();
        query.Query = "<Query><OrderBy><FieldRef Name='Sequence Number' /></OrderBy></Query>";

        SPList manualList = site.Lists["Published Manuals"];
        SPListItemCollection manuals = manualList.GetItems(query);

so i was attempting to get the items of a list sorted by a custom column by using LINQ doing the following.

  SPListItemCollection manuals = manualList.Items.OfType<SPListItem>().OrderBy();

I don't however know how to get it to sort by my column inside of the "OrderBy", any pointers or suggestions as to why the CAML did not work or how to get the Order By to work would be very much appreciated

Thanks in advanced!

1 Answer 1

2

Use CAML, it will give you better performance.

You should skip the

<Query>

And

</Query>

From your SPQuery.Query, so just start with

<OrderBy> 

So

query.Query = "<OrderBy><FieldRef Name='Sequence Number' /></OrderBy>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.