OData with EF and automapper: Cannot compare..'. Only primitive types, enumeration types and entity types are supported -


had odata v3 endpoint ef 6.1.3 , automapper 6.1.1.

datamodel,

  • order, 1 many orderlines

    public partial class order { [system.diagnostics.codeanalysis.suppressmessage("microsoft.usage", "ca2214:donotcalloverridablemethodsinconstructors")] public order() { this.orderlines = new hashset(); }

    public system.guid orderid { get; set; } public string orderplacedby { get; set; } public nullable<system.datetime> placedtime { get; set; }  [system.diagnostics.codeanalysis.suppressmessage("microsoft.usage", "ca2227:collectionpropertiesshouldbereadonly")] public virtual icollection<orderline> orderlines { get; set; } 

    }

  • orderlines

    public partial class orderline { public system.guid orderlineid { get; set; } public nullable orderid { get; set; } public nullable amount { get; set; }

        public virtual order order { get; set; } } 

automapper code,

cfg =>             {                 cfg.allownulldestinationvalues = true;                 cfg.allownullcollections = true;                 cfg.sourcemembernamingconvention = new lowerunderscorenamingconvention();                 cfg.destinationmembernamingconvention = new pascalcasenamingconvention();                 cfg.recognizedestinationprefixes("dto_");                  cfg.createmap<order, orderdto>()                     .formember(d=>d.orderlines,o=>o.allownull())                     .formember(d=>d.orderlines,o=>o.mapfrom(s=>s.orderlines));                 cfg.createmap<orderline, orderlinedto>();             }); 

now if browse url

http://localhost:34354/odata/order?$expand=orderlines

it complaining error below

cannot compare 'member 'orderlines' of type 'c4codata.orderdto''. primitive types, enumeration types , entity types supported.

what did did wrong? has struggled me days, please help!!

i've uploaded repo https://github.com/ninithepug/odata

the thing is, you're using database first. tests use code first , that's works. should too. working gist.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -