JsonPatchDocument<TModel> Class

Namespace
Microsoft.AspNetCore.JsonPatch
Assemblies
  • Microsoft.AspNetCore.JsonPatch

Syntax

[JsonConverter(typeof (TypedJsonPatchDocumentConverter))]
public class JsonPatchDocument<TModel> : IJsonPatchDocument where TModel : class
class Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

Constructors

JsonPatchDocument()
public JsonPatchDocument()
JsonPatchDocument(System.Collections.Generic.List<Microsoft.AspNetCore.JsonPatch.Operations.Operation<TModel>>, Newtonsoft.Json.Serialization.IContractResolver)
public JsonPatchDocument(List<Operation<TModel>> operations, IContractResolver contractResolver)

Methods

Add<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, TProp)

At value at end of list

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • value (TProp) – value
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Add<TProp>(Expression<Func<TModel, IList<TProp>>> path, TProp value)
Add<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, TProp, System.Int32)

Add value to list at given position

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • value (TProp) – value
  • position (System.Int32) – position
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Add<TProp>(Expression<Func<TModel, IList<TProp>>> path, TProp value, int position)
Add<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, TProp)

Add operation. Will result in, for example, { “op”: “add”, “path”: “/a/b/c”, “value”: [ “foo”, “bar” ] }

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
  • value (TProp) – value
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Add<TProp>(Expression<Func<TModel, TProp>> path, TProp value)
ApplyTo(TModel)

Apply this JsonPatchDocument

Arguments:objectToApplyTo (TModel) – Object to apply the JsonPatchDocument to
public void ApplyTo(TModel objectToApplyTo)
ApplyTo(TModel, Microsoft.AspNetCore.JsonPatch.Adapters.IObjectAdapter)

Apply this JsonPatchDocument

Arguments:
public void ApplyTo(TModel objectToApplyTo, IObjectAdapter adapter)
ApplyTo(TModel, System.Action<Microsoft.AspNetCore.JsonPatch.JsonPatchError>)

Apply this JsonPatchDocument

Arguments:
public void ApplyTo(TModel objectToApplyTo, Action<JsonPatchError> logErrorAction)
Copy<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>)

Copy from a position in a list to the end of another list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – source location
  • positionFrom (System.Int32) – position
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Copy<TProp>(Expression<Func<TModel, IList<TProp>>> from, int positionFrom, Expression<Func<TModel, IList<TProp>>> path)
Copy<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32)

Copy from a position in a list to a new location in a list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – source location
  • positionFrom (System.Int32) – position (source)
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • positionTo (System.Int32) – position (target)
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Copy<TProp>(Expression<Func<TModel, IList<TProp>>> from, int positionFrom, Expression<Func<TModel, IList<TProp>>> path, int positionTo)
Copy<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32, System.Linq.Expressions.Expression<System.Func<TModel, TProp>>)

Copy from a position in a list to a new location

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – source location
  • positionFrom (System.Int32) – position
  • path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Copy<TProp>(Expression<Func<TModel, IList<TProp>>> from, int positionFrom, Expression<Func<TModel, TProp>> path)
Copy<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>)

Copy to the end of a list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – source location
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Copy<TProp>(Expression<Func<TModel, TProp>> from, Expression<Func<TModel, IList<TProp>>> path)
Copy<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32)

Copy from a property to a location in a list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – source location
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • positionTo (System.Int32) – position
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Copy<TProp>(Expression<Func<TModel, TProp>> from, Expression<Func<TModel, IList<TProp>>> path, int positionTo)
Copy<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, System.Linq.Expressions.Expression<System.Func<TModel, TProp>>)

Copy the value at specified location to the target location. Willr esult in, for example: { “op”: “copy”, “from”: “/a/b/c”, “path”: “/a/b/e” }

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – source location
  • path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Copy<TProp>(Expression<Func<TModel, TProp>> from, Expression<Func<TModel, TProp>> path)
GetOperations()
Return type:System.Collections.Generic.IList<Microsoft.AspNetCore.JsonPatch.Operations.Operation>
IList<Operation> IJsonPatchDocument.GetOperations()
Move<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>)

Move from a position in a list to the end of another list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – source location
  • positionFrom (System.Int32) – position
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Move<TProp>(Expression<Func<TModel, IList<TProp>>> from, int positionFrom, Expression<Func<TModel, IList<TProp>>> path)
Move<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32)

Move from a position in a list to another location in a list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – source location
  • positionFrom (System.Int32) – position (source)
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • positionTo (System.Int32) – position (target)
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Move<TProp>(Expression<Func<TModel, IList<TProp>>> from, int positionFrom, Expression<Func<TModel, IList<TProp>>> path, int positionTo)
Move<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32, System.Linq.Expressions.Expression<System.Func<TModel, TProp>>)

Move from a position in a list to a new location

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – source location
  • positionFrom (System.Int32) – position
  • path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Move<TProp>(Expression<Func<TModel, IList<TProp>>> from, int positionFrom, Expression<Func<TModel, TProp>> path)
Move<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>)

Move to the end of a list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – source location
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Move<TProp>(Expression<Func<TModel, TProp>> from, Expression<Func<TModel, IList<TProp>>> path)
Move<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32)

Move from a property to a location in a list

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – source location
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • positionTo (System.Int32) – position
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Move<TProp>(Expression<Func<TModel, TProp>> from, Expression<Func<TModel, IList<TProp>>> path, int positionTo)
Move<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, System.Linq.Expressions.Expression<System.Func<TModel, TProp>>)

Removes value at specified location and add it to the target location. Will result in, for example: { “op”: “move”, “from”: “/a/b/c”, “path”: “/a/b/d” }

Arguments:
  • from (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – source location
  • path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Move<TProp>(Expression<Func<TModel, TProp>> from, Expression<Func<TModel, TProp>> path)
Remove<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>)

Remove value from end of list

Arguments:path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
Return type:Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>
public JsonPatchDocument<TModel> Remove<TProp>(Expression<Func<TModel, IList<TProp>>> path)
Remove<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, System.Int32)

Remove value from list at given position

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • position (System.Int32) – position
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Remove<TProp>(Expression<Func<TModel, IList<TProp>>> path, int position)
Remove<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>)

Remove value at target location. Will result in, for example, { “op”: “remove”, “path”: “/a/b/c” }

Arguments:path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
Return type:Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>
public JsonPatchDocument<TModel> Remove<TProp>(Expression<Func<TModel, TProp>> path)
Replace<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, TProp)

Replace value at end of a list

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • value (TProp) – value
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Replace<TProp>(Expression<Func<TModel, IList<TProp>>> path, TProp value)
Replace<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>, TProp, System.Int32)

Replace value in a list at given position

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, System.Collections.Generic.IList<TProp>>>) – target location
  • value (TProp) – value
  • position (System.Int32) – position
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Replace<TProp>(Expression<Func<TModel, IList<TProp>>> path, TProp value, int position)
Replace<TProp>(System.Linq.Expressions.Expression<System.Func<TModel, TProp>>, TProp)

Replace value. Will result in, for example, { “op”: “replace”, “path”: “/a/b/c”, “value”: 42 }

Arguments:
  • path (System.Linq.Expressions.Expression<System.Func<TModel, TProp>>) – target location
  • value (TProp) – value
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>

public JsonPatchDocument<TModel> Replace<TProp>(Expression<Func<TModel, TProp>> path, TProp value)

Properties

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>.ContractResolver
Return type:Newtonsoft.Json.Serialization.IContractResolver
[JsonIgnore]
public IContractResolver ContractResolver { get; set; }
Microsoft.AspNetCore.JsonPatch.JsonPatchDocument<TModel>.Operations
Return type:System.Collections.Generic.List<Microsoft.AspNetCore.JsonPatch.Operations.Operation<TModel>>
public List<Operation<TModel>> Operations { get; }