如何添加OrderBy(a=>a.SortField)
或按“SortField”
var slideShowProducts = _contentManager.Query<JewelleryProductPart, JewelleryProductPartRecord>("JewelleryProduct")
.Join<CustomPropertiesPartRecord>()
.Where(cpp => cpp.CustomOne == catViewModel.Number)
.Join<BodyPartRecord>()
.List()
.Select(sp => new SlideShowProductViewModel
{
Count = sp.Count,
CategoryName = sp.Fields.Single(f => f.PartFieldDefinition.Name == "Category").Storage.Get<string>(""),
SortField = sp.Fields.Single(f => f.PartFieldDefinition.Name == "Sort Field").Storage.Get<string>(""),
Description = sp.Get<BodyPart>().Text
}).ToList();
SlideShowProductsViewModel products = new SlideShowProductsViewModel();
products.Number = catViewModel.Number;
products.CategoryName = catViewModel.Name;
products.SlideShowProducts = slideShowProducts;
productList.Add(products);
答案 0 :(得分:0)
您是否尝试过以下操作?
products.SlideShowProducts =slideShowProducts.OrderBy(a=>a.SortField).ToList();