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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -