I'm not sure if this is a C# question or an Umbraco question but the image explains everything.
So, .OrderBy("SortOrder") is obsolete. I can't find the strongly typed version of it in the Umbraco documentation. will someone be able to point me to the correct direction on where can I find it?
I can't send the whole code because it's a big view, but this is the gist of it.
Is there within umbraco documentation a better way to do sort order than the one that is about to be obsolete?
Actually I think the collection is returned in sort order, so I don't think it is necessary unless you want to sort in descending order or by another property.
If not the collection is in right sort order, it need to be sorted first if you not just want the first 6 items no matter which default order the collection has.
.OrderBy("SortOrder") obsolete Umbraco 7.7
Hello once again,
I'm not sure if this is a C# question or an Umbraco question but the image explains everything.
So, .OrderBy("SortOrder") is obsolete. I can't find the strongly typed version of it in the Umbraco documentation. will someone be able to point me to the correct direction on where can I find it?
Or which one is the one that I should use?
Hi Harry
Yes, use strongly typed models, please.
Thanks,
Alex
Show me all the code of view?
Hi Alex, this is what I have:
I can't send the whole code because it's a big view, but this is the gist of it. Is there within umbraco documentation a better way to do sort order than the one that is about to be obsolete?
Thanks for the reply Alex.
Hi Harry
Try this code:
That's what I was looking for. It's just C# isn't it? It doesn't have to do with Umbraco. I appreciate it.
Yes, it's just c#, have a look at all properties and helpers here : https://our.umbraco.org/documentation/reference/querying/ipublishedcontent/
THanks,
Alex
@Alex @Harry
I guess you would sort the collection before selecting 6 items, right?
/Bjarne
Hi Bjarne
It depends on business needs :) I'm not sure how it should be sorted.
Sort only 6 items - faster, but it can return wrong results of course if you need top 6 items sorted before
Hi Bjarne,
I think it's the same thing in my case. I'll test it when the client adds content on the staging server and I'll let you know, if you're interested.
Hello, One of the reasons that is obsolete, is that this method uses Dynamic. which will be discontinued in v8.
https://our.umbraco.org/documentation/reference/Common-Pitfalls/#dynamics
Actually I think the collection is returned in sort order, so I don't think it is necessary unless you want to sort in descending order or by another property.
If not the collection is in right sort order, it need to be sorted first if you not just want the first 6 items no matter which default order the collection has.
/Bjarne
Ah, I didn't think of that. I'll test it out and see
is working on a reply...