Open sandboxFocus

Method AddOrApplyChanges

AddOrApplyChanges<TKey, TValue>(TValue)

Creates a new IncrementalKeyedCollection<TKey, TValue> that represents the operation of adding an item to the collection, or merging it with an existing item if the same key already exists.

Declaration
public static IncrementalKeyedCollection<TKey, TValue> AddOrApplyChanges<TKey, TValue>(TValue item) where TKey : notnull where TValue : class, IIncrementalKeyedCollectionItem<TKey>
Parameters
Type Name Description
TValue item

The item to add or merge into the collection.

Returns
Type Description
IncrementalKeyedCollection<TKey, TValue>

An IncrementalKeyedCollection<TKey, TValue> representing the add or merge operation.

Type Parameters
Name Description
TKey

The type of keys in the collection.

TValue

The type of values in the collection.

Remarks

If an item with the same key exists in a previous layer, the two items are merged using ApplyChanges(object, in ApplyChangesContext).

AddOrApplyChanges<TKey, TValue>(params TValue[])

Creates a new IncrementalKeyedCollection<TKey, TValue> that represents the operation of adding items to the collection, or merging them with existing items if the same keys already exist.

Declaration
public static IncrementalKeyedCollection<TKey, TValue> AddOrApplyChanges<TKey, TValue>(params TValue[] items) where TKey : notnull where TValue : class, IIncrementalKeyedCollectionItem<TKey>
Parameters
Type Name Description
TValue[] items

The items to add or merge into the collection.

Returns
Type Description
IncrementalKeyedCollection<TKey, TValue>

An IncrementalKeyedCollection<TKey, TValue> representing the add or merge operations.

Type Parameters
Name Description
TKey

The type of keys in the collection.

TValue

The type of values in the collection.

Remarks

For each item, if an item with the same key exists in a previous layer, the two items are merged using ApplyChanges(object, in ApplyChangesContext).

AddOrApplyChanges<TKey, TValue>(IEnumerable<TValue>)

Creates a new IncrementalKeyedCollection<TKey, TValue> that represents the operation of adding items to the collection, or merging them with existing items if the same keys already exist.

Declaration
public static IncrementalKeyedCollection<TKey, TValue> AddOrApplyChanges<TKey, TValue>(IEnumerable<TValue> items) where TKey : notnull where TValue : class, IIncrementalKeyedCollectionItem<TKey>
Parameters
Type Name Description
IEnumerable<TValue> items

The items to add or merge into the collection.

Returns
Type Description
IncrementalKeyedCollection<TKey, TValue>

An IncrementalKeyedCollection<TKey, TValue> representing the add or merge operations.

Type Parameters
Name Description
TKey

The type of keys in the collection.

TValue

The type of values in the collection.

Remarks

For each item, if an item with the same key exists in a previous layer, the two items are merged using ApplyChanges(object, in ApplyChangesContext).