且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我在控制器中遇到错误

更新时间:2023-02-19 18:30:16

您的代码:

your code:
public ActionResult Index()
        {
            var Q = from a in _ObjectEntities.Events
                     join b in _ObjectEntities.Employees on a.Incharge equals b.Id
                     select new {
                         EventId = a.EventId,
                         EventName = a.EventName,
                         EventType = a.EventType,
                         EventDate = a.EventDate,
                         Incharge = b.Name
                     };
 
            
            return View(Q.AsEnumerable());
        }





更改为:





Change to this:

public ActionResult Index()
        {
            var Q = from a in _ObjectEntities.Events
                     join b in _ObjectEntities.Employees on a.Incharge equals b.Id
                     select new EventsModel {
                         EventId = a.EventId,
                         EventName = a.EventName,
                         EventType = a.EventType,
                         EventDate = a.EventDate,
                         Incharge = b.Name
                     };
 
            
            return View(Q.AsEnumerable());
        }