Our project is a .NET Core Web API with a RavenDB backend and an angular 4 frontend.
In the Web API, I have a model as follows
public abstract class Offer
{
public int MerchantId { get; set; }
...
}
public class BasicOffer : Offer
{
public int OfferId { get; set; }
public string Description { get; set; }
}
public class StandardOffer : BasicOffer
{
public string ImageUrl { get; set; }
}
public class Section
{
...
public ICollection<Offer> offers { get; set; }
}
public class Hub
{
...
public ICollection<Section> sections { get; set; }
}
In our Angular app, we have the exact same models.
When try to update data using a POST request, the data sent by the Angular app contains the extra properties in the derived BasicOffer
class, but when that data arrives at the Web API it only contains the properties in the base Offer
class.
When I say "arrives", I mean putting a breakpoint on the first line of the POST request on the controller and looking at the parameters passed in.
Basically, how do I store data from a derived abstract class?
Thanks