我正在使用ProductViewModel中的产品填充部分视图。当模型返回时,我们有...
var viewModel = _productAgent.GetProductsByCatalog(catalogId);
viewModel是ProductViewModel集合。
我正在使用linq按照创建日期降序排列的方式来限制集合大小,仅保留前10个产品,代码如下...
var newList = (from p in viewModel
//from pf in p.DomainObjectFields
select p).Distinct().OrderByDescending(d => d.CreateDate).Take(10);
我尝试加载部分内容...
return PartialView("_ProductGrid", viewModel);
问题在于newList是IEnumerable类型,它需要是一个集合,但我不知道如何转换它,或者我是否采取了正确的方法。