Asp.net mvc 实体或复杂类型';我们的WebsiteModel.Article';无法在LINQ to实体查询中构造
我编写了以下代码以从Entity Framework获取文章:Asp.net mvc 实体或复杂类型';我们的WebsiteModel.Article';无法在LINQ to实体查询中构造,asp.net-mvc,linq-to-entities,Asp.net Mvc,Linq To Entities,我编写了以下代码以从Entity Framework获取文章: //return type of Items is 'IQueryable<Article>' var articleToList = _articleRepo.Items; var viewModel = new TopArticlesViewModel { Articles =articleToList.Skip((page - 1) * PageSize).Take(PageSize), Pagi
//return type of Items is 'IQueryable<Article>'
var articleToList = _articleRepo.Items;
var viewModel = new TopArticlesViewModel
{
Articles =articleToList.Skip((page - 1) * PageSize).Take(PageSize),
PagingInfo = new PagingInfo
{
CurrentPage = page,
ItemsPerPage = PageSize,
TotalItems = articleToList.Count()
}
};
//项目的返回类型为'IQueryable'
var articleToList=\u articleRepo.Items;
var viewModel=新的TopArticlesViewModel
{
Articles=articleToList.Skip((第1页)*页面大小)。Take(页面大小),
PaginInfo=新的PaginInfo
{
CurrentPage=第页,
ItemsPerPage=页面大小,
TotalItems=articleToList.Count()
}
};
下面是TopArticlesViewModel类定义:
public class TopArticlesViewModel
{
public IQueryable<Article> Articles { get; set; }
public PagingInfo PagingInfo { get; set; }
}
公共类TopArticlesViewModel
{
公共IQueryable项目{get;set;}
公共分页信息分页信息{get;set;}
}
但当我在asp.net mvc中运行应用程序时,出现以下错误:
无法创建实体或复杂类型“ourWebItemModel.Article”
在LINQ to实体查询中构造。描述:一个未处理的
执行当前web请求期间发生异常。
请查看堆栈跟踪以了解有关错误和错误的更多信息
它起源于代码的地方
异常详细信息:System.NotSupportedException:实体或复合体
无法在LINQ to中构造类型“ourWebItemodel.Article”
实体查询
看到了吗,但是我所有的元数据类都是基于实体类的,还有其他方法吗?