c# - Valueinjecter map base derived class -


i have base class ad.

public class ad {     public int id{get;set;}      public string title{get;set;}      public string price{get;set;} } 

then have lot of derived classes like:

public class carad : ad {     public string modelname {get;set;} }  public class mobilead : ad {     public string companyname {get;set;} } 

and accordingly have viewmodels these classes well.

public class adviewmodel {     public int id{get;set;}      public string title{get;set;}      public string price{get;set;} }  public class caradviewmodel : adviewmodel {     public string modelname {get;set;} }  public class mobileadviewmodel : adviewmodel {     public string companyname {get;set;} } 

i trying map derived class base class using value injecter. like:

    [httppost]     public async task<ihttpactionresult> post([frombody] caradviewmodel caradmodel)     {         var ad = new ad();         ad.injectfrom(caradmodel);     } 

but not mapping properties of derived class. can tell me if possible?


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

html - Is there any way to exclude a single element from the style? (Bootstrap) -

Delphi 7 and decode UTF-8 base64 -