类型'System.NullReferenceException'的例外

时间:2016-02-04 07:22:00

标签: model-view-controller

这在我的行动方法中,我得到例外。

public ViewResult List(string category, int page = 1)
{
    ProductsListViewModel model = new ProductsListViewModel {[enter image description here][1]
        Products = repository.Products
            .Where(p => category != null || p.Category == category)
            .OrderBy(p => p.ProductID).Skip((page - 1) * PageSize)
            .Take(PageSize),

        PagingInfo = new PagingInfo{
            CurrentPage = page,
            ItemsPerPage = PageSize,
            TotalItems = category == null 
                ? repository.Products.Count() 
                : repository.Products.Where(p => p.Category == category).Count()
        },

        CurrentCategory = category
};

MyProject.DLL中发生了'System.NullReferenceException'类型的异常,但未在用户代码中处理 //这里是跟踪

0 个答案:

没有答案