Question

Rather than expose my Database Model I'm trying to get my WebAPI endpoints working with DTO equivalents. In my WebAPIConfig referenced from the Global.asax file I have:

builder.EntitySet<ProductDTO>("Products");
builder.EntitySet<Product>("ProductsDB");

Where Product has an extra field that ProductDTO does not have.

My patch request is currently:

[AcceptVerbs("PATCH", "MERGE")]
public IHttpActionResult Patch([FromODataUri] int key, Delta<ProductDTO> patch)
{

I can see that essentially I need to convert my Delta<ProductDTO> into a Delta<Product> but I cannot see any methods in the Delta class that would allow me to set its underlying EntityType instance.

Does anyone have any advice?

Was it helpful?

Solution

This question is very similar to yours, please reference it:

Microsoft Odata api through a ViewModel has problems in PATCH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top