Hi @wavemaster ,
You need change like below:
[Route("UpdatePartial/{id}")]
[HttpPatch]
public async Task<IActionResult> Patch(int id, bool hasQbWc, [FromBody] JsonPatchDocument<TxnBillingPatch> txnPatch)
{
if (txnPatch == null) { return BadRequest(); }
var theTxn = new Transaction() { Id = 1, TransName = "trans1" };
//add this....
var data = new TxnBillingPatch();
data.Transaction = theTxn;
txnPatch.ApplyTo(data, ModelState);
var isValid = TryValidateModel(theTxn);
if (!isValid) { return BadRequest(ModelState); }
//await context.SaveChangesAsync();
return new ObjectResult(data);
}
JSON patch example:
[
{
"op":"add",
"path":"/TestViewModel",
"value":[{
"id":1,
"testName":"aa"
}]
}
]
Result:
{
"transaction": {
"id": 1,
"transName": "trans1"
},
"testViewModel": [
{
"id": 1,
"testName": "aa"
}
]
}
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
Rena