C# ASP.NET MVC LINQ:加入另一个正在运行的模型
我想将另一个模型加入到我当前的MVC操作中,以便能够读取视图中的外键。我想将“ProductiveUnit”模型加入下面的操作,其中ProductiveUnit在Produnid上的EventTaskViewModel上加入。ProductiveUnit中的所有字段都可以在视图中使用,或者只有“ProdUnitNo”不重要。根据以下LINQ,请告知如何在EventGantt\u Read操作中执行此操作:C# ASP.NET MVC LINQ:加入另一个正在运行的模型,c#,asp.net-mvc,linq,controller,telerik-mvc,C#,Asp.net Mvc,Linq,Controller,Telerik Mvc,我想将另一个模型加入到我当前的MVC操作中,以便能够读取视图中的外键。我想将“ProductiveUnit”模型加入下面的操作,其中ProductiveUnit在Produnid上的EventTaskViewModel上加入。ProductiveUnit中的所有字段都可以在视图中使用,或者只有“ProdUnitNo”不重要。根据以下LINQ,请告知如何在EventGantt\u Read操作中执行此操作: public ActionResult EventGantt\u Read([DataSo
public ActionResult EventGantt\u Read([DataSourceRequest]DataSourceRequest请求,int[]PUID)
{
var data=(来自db.Events.Where(t=>PUID.Contains((int)t.ProductiveUnitID)中的e)
将p连接到e.ProductiveUnitID上的db.ProductiveUnits中等于p.ProdUnitID
选择新{EventID=e.EventID,EventDescription=e.EventDescription,ProductiveUnitID=e.ProductiveUnitID,ActualStart=e.ActualStart,ActualLend=e.ActualLend,ParentEventID=e.ParentEventID,ActivityCodeID=e.ActivityCodeID,ProdUnitNo=p.ProdUnitNo})
.选择(eventList=>new EventTaskViewModel(eventList))
.AsQueryable();
返回Json(data.ToDataSourceResult(request));
}
通过上面的查询,我在以下行中得到一个错误:
.Select(eventList => new EventTaskViewModel(eventList))
在
eventList
上,saying cannot convert from'代替new{EventID=…
writenew Event{EventID=…