I'm having a bit of trouble trying to order some results from a for loop. I'm not very good with razor, so getting the syntax right is killing my brain off! I'm not sure if I need to be looking into the .Where expression or the for loop itself.
I'd like the months to be outputted by publishDate Descending.
Sorry - forgot to mention that publishDate was a field I have added. Would this explain the following error?
error CS1061: 'umbraco.MacroEngines.DynamicNode' does not contain a definition for 'publishDate' and no extension method 'publishDate' accepting a first argument of type 'umbraco.MacroEngines.DynamicNode' could be found (are you missing a using directive or an assembly reference?)
error CS0411: The type arguments for method 'System.Linq.Enumerable.OrderBy(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
OrderBy For loop
Hey guys,
I'm having a bit of trouble trying to order some results from a for loop. I'm not very good with razor, so getting the syntax right is killing my brain off! I'm not sure if I need to be looking into the .Where expression or the for loop itself.
I'd like the months to be outputted by publishDate Descending.
Any help would be much appreciated!
Thanks,
Tom
Hi Tom,
Could you then try to do something like this to see if this will work for you.
Hope this helps,
/Dennis
Thanks for the quick response Dennis.
Sorry - forgot to mention that publishDate was a field I have added. Would this explain the following error?
Hi Tom,
Okay what if you just do:
Would this work for you then, or are you getting the same error?
/Dennis
Slightly different error this time..
Try
posts.OrderByDescending(x => x.GetPropertyValue("publishDate"))
. :)Perfect. :)
Thanks Lars-Erik.
is working on a reply...