0

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

1 回答 1

0

您是否尝试过以下操作?

products.SlideShowProducts =slideShowProducts.OrderBy(a=>a.SortField).ToList();
于 2012-07-24T21:14:04.503 回答