If I uncomment out the OrderByDescending line below(and only use one semicolon, of course), I get a null exception at the start of my foreach loop. Why could this be happening?
@{ var rootNode = Model.AncestorContentOrSelf().Last(); var L1Pages = rootNode.Children() .Where(x => x.ContentType.Alias == "navigationItem"); //.OrderByDescending(x => x.SortOrder); }
@foreach (var L1Page in L1Pages) {...}
I can successfully use OrderByDescending on another template...
Seems like it has something to do with the bad statement returning an IQueryable(), and the good statement below return IEnumerable(), but I've tried lots of statements and still can't get it to work.
I'm starting to think there is a bug in Umbraco 5 because this is such a simple statement. I have changed it 20 ways, but no luck. No one else is seeing an error when trying to OrderByDescending?
NullReferenceException' occurred in Umbraco.Framework.Persistence.NHibernate.DLL
The statement only works when I remove .OrderByDescending(x => x.SortOrder)
@inherits RenderViewPage @using Umbraco.Cms.Web;
@{ var rootNode = Model.AncestorContentOrSelf().Last(); var L1Pages = rootNode.Children() .Where(x => x.ContentType.Alias == "navigationItem") .OrderByDescending(x => x.SortOrder); }
If I change the previous statement to use AsEnumerable() it will execute without errors, however, all of the SortOrders are always zero so, as I'd expect, .OrderBy() and .OrderByDescending() don't affect the results. I've sorted all of my content to make sure they have actual values. So is this an Umbraco bug I should report?
var rootNode = Model.AncestorContentOrSelf().Last(); var L1Pages = rootNode.Children().AsEnumerable() .Where(x => x.ContentType.Alias == "navigationItem") .OrderByDescending(x => x.SortOrder);
.OrderByDescending returns null
Umbraco 5.
If I uncomment out the OrderByDescending line below(and only use one semicolon, of course), I get a null exception at the start of my foreach loop. Why could this be happening?
I can successfully use OrderByDescending on another template...
Seems like it has something to do with the bad statement returning an IQueryable(), and the good statement below return IEnumerable(), but I've tried lots of statements and still can't get it to work.
I'm starting to think there is a bug in Umbraco 5 because this is such a simple statement. I have changed it 20 ways, but no luck. No one else is seeing an error when trying to OrderByDescending?
NullReferenceException' occurred in Umbraco.Framework.Persistence.NHibernate.DLL
The statement only works when I remove .OrderByDescending(x => x.SortOrder)
If I change the previous statement to use AsEnumerable() it will execute without errors, however, all of the SortOrders are always zero so, as I'd expect, .OrderBy() and .OrderByDescending() don't affect the results. I've sorted all of my content to make sure they have actual values. So is this an Umbraco bug I should report?
is working on a reply...