我的 SQL 数据库中有两张表,一张用于存储代理AgentTransmission
(TransmissionHistory
)。
我需要AgentTransmission
根据基于表格日期的过滤器集从表格中获取信息TransmissionHistory
。但是,由于我需要将其发送到的视图正在寻找@model IEnumerable<Monet.Models.AgentTransmission>
我收到以下错误
The model item passed into the dictionary is of type 'System.Collections.Generic.List1[<>f__AnonymousTypeb'18[System.String,System.String,System.String,System.String,System.String,System.String,System.Int64,System.String,System.String,System.Nullable'1[System.DateTime],System.Boolean,System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable'1[System.DateTime]]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable'1[Monet.Models.AgentTransmission]'.
我对 Linq/Entity Framework 还是很陌生,所以如果有人能给我一个关于正在发生的事情的提示,我将不胜感激。谢谢!
var agents = (from a in db.AgentTransmission
join t in db.TransmissionHistory on
a.ID equals t.TranTableId
where a.RecordStatus.Equals("C") &&
a.WelcomeLetter &&
t.ReplyResult.Equals("S") &&
EntityFunctions.DiffDays(t.TransmittedOn, startDate) <= 0 &&
EntityFunctions.DiffDays(t.TransmittedOn, endDate) >= 0
select new
{
a.BankName,
a.DRMCompanyName,
a.Pendist,
a.FirstName,
a.LastName,
a.MiddleInitial,
a.ReferenceNumber,
a.AgencyId1,
a.AgencyIdType1,
a.EffectiveDate,
a.JIT,
a.Email,
a.LocationStreet1,
a.LocationStreet2,
a.LocationCity,
a.LocationState,
a.LocationZip,
a.CreatedDate
});
return View(agents.ToList());