我创建了一个视图模型:-
public class viewdata : Tool.Models.Administration.User
{
public string Categories { get; set; }
public int RegionID { get; set; }
public string RegionName { get; set; }
}
它首先是在 Controller 中创建的。然后我将其位置更改为 Tool.Models.Derived.viewdata ..然后在控制器中的 Lists Actionresult 中出现错误
public ActionResult Lists(int? page)
{
var ListIFC = (from f in _db.Users
where f.IsActive == 1 && f.UserType == 2
select new viewdata
{
UserName=f.UserName,
FirstName = f.FirstName,
UserID=f.UserID
});
List<Tool.Models.Derived.viewdata> obj = (List<Tool.Models.Derived.viewdata>)ListIFC.ToList();
int pageSize = 3;
int pageNumber = (page ?? 1);
return View(obj.ToPagedList(pageNumber, pageSize));
}
我收到这样的错误...
The entity or complex type 'Tool.Models.viewdata' cannot be constructed in a LINQ to Entities query.