I m, using MVC3 ajaxgrid scafrafting with EF4.1 Code first and i ve this差错:
不可含蓄地转换类型系统。 Linq.I Queryable to System.Data.Objects.ObjectQuery
错误的法典是自动产生的:
public ActionResult GridData(int start = 0, int itemsPerPage = 20, string orderBy = "UserID", bool desc = false)
{
Response.AppendHeader("X-Total-Row-Count", repository.Users.Count().ToString());
ObjectQuery<User> users = (repository as IObjectContextAdapter).ObjectContext.CreateObjectSet<User>();
users = repository.Users.Include(u => u.Role); //ERROR HERE
users = users.OrderBy("it." + orderBy + (desc ? " desc" : ""));
return PartialView(users.Skip(start).Take(itemsPerPage));
}
这是用户存放方法以及外国钥匙的作用。
public IQueryable<Entities.User> Users
{
get { return context.Users; }
}
public IQueryable<Entities.Role>Roles
{
get { return context.Roles; }
}
如何解决转换问题?