Used to group massive changes to entities and to allow manual explicit changes of entity states.

Namespace:  C1.Data
Assembly:  C1.Data.Entity (in C1.Data.Entity.dll)

Syntax

C#
public void BulkChanges(
	Action makeChanges
)
Visual Basic
Public Sub BulkChanges ( _
	makeChanges As Action _
)

Parameters

makeChanges
Type: System..::..Action
A delegate that makes changes in entities.

Remarks

Internal state of the client-side cache and all existing client views based on the cache are kept unchanged, aren't updated while the given makeChanges is executed. After the delegate completes its execution (having modified multiple entities), the client-side cache internal state is restored and client views are updated (maintained) to reflect the changes made in entities during the delegate's execution.

There are two main scenarios where you should consider calling this method:

  1. Using this method when you make a lot of changes to entities can improve performance because the change processing is deferred, occurs only once after all changes are done instead of every time on each change. Depending on the amount of changes, the speedup can be considerable.
  2. You must use this method when you need to make changes to entity states by calling any of the following methods:
    • System.Data.Objects.ObjectStateEntry.ChangeState/SetModified/AcceptChanges,
    • System.Data.Objects.ObjectContext.AcceptAllChanges,
    • System.ServiceModel.DomainServices.Client.DomainContext.RejectChanges,
    • System.ServiceModel.DomainServices.Client.Entity.AcceptChanges/RejectChanges,
    • System.ServiceModel.DomainServices.Client.EntitySet.AcceptChanges/RejectChanges,
    • System.Windows.Controls.DomainDataSource.RejectChanges.
Calling these methods without wrapping them with BulkChanges(Action) can corrupt the client-side cache.

Examples

Copy CodeC#
var scope = clientCache.CreateScope();
clientCache.BulkChanges(delegate {
    foreach(var detail in scope.GetItems<Order_Details>)
        detail.Discount *= 2;
});

See Also