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
Post a Comment