Table of Contents

Class PatchOperation

Namespace
Microsoft.Azure.Cosmos
Assembly
Microsoft.Azure.Cosmos.Client.dll

Details of Patch operation that is to be applied to the referred Cosmos item.

public abstract class PatchOperation
Inheritance
PatchOperation
Derived
Inherited Members
Extension Methods

Constructors

PatchOperation()

protected PatchOperation()

Properties

From

Source location reference (used in case of move)

public virtual string From { get; set; }

Property Value

string

OperationType

Patch operation type.

public abstract PatchOperationType OperationType { get; }

Property Value

PatchOperationType

Path

Target location reference.

public abstract string Path { get; }

Property Value

string

Methods

Add<T>(string, T)

Create PatchOperation<T> to add a value.

public static PatchOperation Add<T>(string path, T value)

Parameters

path string

Target location reference.

value T

The value to be added.

Returns

PatchOperation

PatchOperation instance for specified input.

Type Parameters

T

Type of value

Increment(string, double)

Create PatchOperation to Increment a value.

public static PatchOperation Increment(string path, double value)

Parameters

path string

Target location reference.

value double

The value to be Incremented by at the specified path.

Returns

PatchOperation

PatchOperation instance for specified input.

Increment(string, long)

Create PatchOperation to Increment a value.

public static PatchOperation Increment(string path, long value)

Parameters

path string

Target location reference.

value long

The value to be Incremented by at the specified path.

Returns

PatchOperation

PatchOperation instance for specified input.

Move(string, string)

Create PatchOperation to move an object/value.

public static PatchOperation Move(string from, string path)

Parameters

from string

The source location of the object/value.

path string

Target location reference.

Returns

PatchOperation

PatchOperation instance for specified input.

Remove(string)

Create PatchOperation to remove a value.

public static PatchOperation Remove(string path)

Parameters

path string

Target location reference.

Returns

PatchOperation

PatchOperation instance for specified input.

Replace<T>(string, T)

Create PatchOperation<T> to replace a value.

public static PatchOperation Replace<T>(string path, T value)

Parameters

path string

Target location reference.

value T

The new value.

Returns

PatchOperation

PatchOperation instance for specified input.

Type Parameters

T

Type of value

Set<T>(string, T)

Create PatchOperation<T> to set a value.

public static PatchOperation Set<T>(string path, T value)

Parameters

path string

Target location reference.

value T

The value to be set at the specified path.

Returns

PatchOperation

PatchOperation instance for specified input.

Type Parameters

T

Type of value

TrySerializeValueParameter(CosmosSerializer, out Stream)

Serializes the value parameter, if specified for the PatchOperation.

public virtual bool TrySerializeValueParameter(CosmosSerializer cosmosSerializer, out Stream valueParam)

Parameters

cosmosSerializer CosmosSerializer

Serializer to be used.

valueParam Stream

Outputs the serialized stream if value parameter is specified, null otherwise.

Returns

bool

True if value is serialized, false otherwise.

Remarks

Output stream should be disposed after use.