SQL データベースに 2 つのテーブルがあります。1 つはエージェント ( AgentTransmission
) を格納するためのもので、もう 1 つはエージェントの送信履歴 ( TransmissionHistory
) をログに記録するものです (エージェントごとにログ テーブルに記録される成功または応答ステータス「S」は 1 つだけです)。 )。
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());