如何将OrderBy添加到ORCHARD中的Query结果中

时间:2012-07-24 17:01:15

标签: asp.net-mvc orchardcms

如何添加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);

1 个答案:

答案 0 :(得分:0)

您是否尝试过以下操作?

products.SlideShowProducts =slideShowProducts.OrderBy(a=>a.SortField).ToList();