DataSource for Entity Framework in WPF
C1.Data Namespace / ClientCacheBase Class / BulkChanges Method
A delegate that makes changes in entities.
Example

In This Topic
    BulkChanges Method
    In This Topic
    Used to group massive changes to entities and to allow manual explicit changes of entity states.
    Syntax
    'Declaration
     
    Public Sub BulkChanges( _
       ByVal makeChanges As Action _
    ) 
    public void BulkChanges( 
       Action makeChanges
    )

    Parameters

    makeChanges
    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 can corrupt the client-side cache.
    Example
    var scope = clientCache.CreateScope();
    clientCache.BulkChanges(delegate {
        foreach(var detail in scope.GetItems<Order_Details>)
            detail.Discount *= 2;
    });
    See Also