Search code examples
c#entity-frameworkodataasp.net-web-api

Patch entity with delta


I have an override that patches an entity.

protected override Books PatchEntity(int key, Delta<Books> patch)
{
    var Book = db.books.FirstOrDefault(p => p.ID== key);
    if (Book == null)
    {
        throw new HttpResponseException(HttpStatusCode.NotFound);
    }

    patch.Patch(Book);
    db.SaveChanges();
    return Book ;
}

What I need to do is intercept it so I can put a business rule, for example : if title has certain words, then reject.

How do I capture the message body that is being sent by the client?


Solution

  • Very simple:

    patch.GetEntity().BookName