c# - this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Monet.Models.AgentTransmission]' -


i have 2 tables in sql database, 1 storing agent (agenttransmission) , other logs transmission history (transmissionhistory) of agent (there 1 successful, or reply status "s", record on logging table per agent).

i need grab information agenttransmission table according filter set based on dates of transmissionhistory table. however, since view need send looking @model ienumerable<monet.models.agenttransmission> getting following error

the model item passed dictionary 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]]]', dictionary requires model item of type 'system.collections.generic.ienumerable'1[monet.models.agenttransmission]'.

i'm pretty new linq/entity framework if can give me hint what's going on appreciated. thanks!

        var agents = (from in db.agenttransmission                         join t in db.transmissionhistory on                             a.id equals t.trantableid                         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()); 

you passing anonymous object view (the new {} part of select) whereas view expects object of type ienumerable<agenttransmission> (because that's used in @model declaration). should coherent in model passing view. ideally design view model , have select statement return new someviewmodel , make view typed @model ienumerable<someviewmodel>.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -