This works fine, but what i want to do is a group by and then an order by operation to create linked comments.
My comment form has a hidden field that contains the recordId of the parent comment. I would like to group by parent recordid and then sort by Created.
Anyone know of orderby or groupby syntax for more than one field using a built-in method such as GetApprovedRecordsFromPage or RecordStorage getrecord or getallrecords?
In shorthand you should be able to do something like this:
@foreach(dynamic record in Umbraco.Forms.Mvc.DynamicObjects.Library.GetApprovedRecordsFromPage(@Model.Id).OrderBy("Created, Name desc")){
}
And longhand syntax looks like this:
@foreach(dynamic record in Umbraco.Forms.Mvc.DynamicObjects.Library.GetApprovedRecordsFromPage(@Model.Id).OrderBy("Created desc").OrderBy("Name desc")){
Thanks for your reply Dennis. Your first exaple give a linq error, the second example deos work but not in the way I expect. What I need is a GroupBy and then a SortBy within the group. I think dynamicobjects does not support GroupBy.
I am going to try record storage an see if that will work.
How do I sortby or groupby more than one field?
I am using this code to get contour records:
foreach (dynamic record in
Umbraco.Forms.Mvc.DynamicObjects.Library.GetApprovedRecordsFromPage(@Model.Id).OrderBy("Created desc"))
{ etc....
This works fine, but what i want to do is a group by and then an order by operation to create linked comments.
My comment form has a hidden field that contains the recordId of the parent comment. I would like to group by parent recordid and then sort by Created.
Is this possible?
Bob
Anyone know of orderby or groupby syntax for more than one field using a built-in method such as GetApprovedRecordsFromPage or RecordStorage getrecord or getallrecords?
Hi Rob,
I thin that you should be able to orderby for more than one field using syntax this syntax. Try to see the documentation here: http://umbraco.com/follow-us/blog-archive/2011/3/1/umbraco-razor-feature-walkthrough-%E2%80%93-part-4
In shorthand you should be able to do something like this:
And longhand syntax looks like this:
Hope this helps,
/Dennis
Thanks for your reply Dennis. Your first exaple give a linq error, the second example deos work but not in the way I expect. What I need is a GroupBy and then a SortBy within the group. I think dynamicobjects does not support GroupBy.
I am going to try record storage an see if that will work.
Bob
is working on a reply...