Hi, I need to sort the GetLoop("Groups") in my razor template.
I use to write Linq so I tryed this List<LoopItem> SortedList = GetLoop("Groups").OrderBy(o=>o.Name).ToList(); but thats not acceptet
Is Linq not supported?
Hi, I need to sort the GetLoop("Groups") in my razor template.
I use to write Linq so I tryed this List<LoopItem> SortedList = GetLoop("Groups").OrderBy(o=>o.Name).ToList(); but thats not acceptet
Is Linq not supported?
Linq is supported since it is .NET, but the GetLoop returns a LoopItem and it does not have a .Name property.
So try this instead: List<LoopItem> SortedList = GetLoop("Groups").OrderBy(o=>o.GetString("Ecom:Group.Name")).ToList();
BR Nicolai
I tryed this but ListItem dos not contain a defination OrderBy
List<LoopItem> SortedList = GetLoop("Groups").OrderBy(o => o.GetString("Ecom:Group.Name")).ToList();
Try this one:
System.Collections.Generic.List<Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>.LoopItem> SortedList = GetLoop("Groups").OrderBy(o => o.GetString("Ecom:Group.Name")).ToList();
Thanks, but it's the same result "ListItem Dos not cotain a definition of OrderBy" System.Collections.Generic.List<Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>.LoopItem> SortedList = GetLoop("Groups").OrderBy(o => o.GetString("Ecom:Group.Name")).ToList();
I'm running DW 8.3.1.1
Does it work if you just write
var groups = GetLoop("Groups").OrderBy(g => g.GetString("Ecom:Group.Name")).ToList();
?
Best regards,
Mikkel
Hi Mikkel,
No it´s the same error:
'System.Collections.Generic.List<Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>.LoopItem>' does not contain a definition for 'OrderBy' and no extension method 'OrderBy' accepting a first argument of type 'System.Collections.Generic.List<Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>.LoopItem>' could be found (are you missing a using directive or an assembly reference?) d:\Projects\xxx\Website\build\Application(8.3.1.1)\Files\Templates\Designs\eCommerce\eCom\GroupList\GroupList.cshtml
Hi Mikkel or someone else :)
Any news about this? can it be done?
I'm unable to reproduce this error. Can you try to set up a new, clean solution and see if you still get this error?
I'm listening in on this, since I have a some how similar issue.
Got an item list containing items.
Employee List -> Containing Employees wich title, phone, etc. (there is a reason for using items given the task's scenario - else the user management would be suffice) ..
However, i was wondering whether it is possible to use LINQ in the following:
//Getting list of different countries (sweden, denmark, germany etc
@foreach(LoopItem i in GetLoop("ItemPublisher:Items.List")) {
//Loop employee list item to get all employees from a given country..
foreach(LoopItem li in i.GetLoop("ItemPublisher:Item.Employee_List").Where(e=>i.GetValue("ItemPublisher:Item.Country_Name") == "Denmark)) {
<div>@li.GetValue("ItemPublisher:Item.Employee_List.Name")</div>
}
I might be doing something completely wrong, however I am able to print all the different employees, but need the specific in the above example..
/MikkelTO
}
Please see my reply on your other post (http://developer.dynamicweb-cms.com/forum.aspx?ThreadID=35204#Reply35206).
Best regards,
Mikkel
You must be logged in to post in the forum