LoadBehavior Enumeration

WCF RIA Services

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Specifies control identity cache behavior when loading entities.

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

public enum LoadBehavior

Member nameDescription
MergeIntoCurrentValues from the newly read instance are merged into the cached instance for property values that are unmodified. No changes are lost in this merge.
KeepCurrentThe cached instance is not changed and the newly read instance is discarded.
RefreshCurrentAll members of the cached instance are overwritten with current values from the newly read instance, regardless of whether they have been modified. In addition, the original state of the entity is also set to the newly read instance.

Each option specifies the merge behavior when an entity that has been previously read and cached is read again.

// Create an EntityQuery of type Customer
EntityQuery<Customer> query =
    from c in _customerContext.GetCustomersQuery()
    where c.Phone.StartsWith("583")
    orderby c.LastName
    select c;

// Create and execute a LoadOperation of type Customer and load 'query'
// LoadBehavior is set to merge this query into the current cache
LoadOperation<Customer> loadOp = this._customerContext.Load(query, LoadBehavior.MergeIntoCurrent, false);

// Create a new DomainOperationException for a Validation Error
DomainOperationException opEx = new DomainOperationException(
    "Validation Error",

// Check if there are any ValidationErrors when loadOp was executed
// Then throw the DomainOperationException opEx
if (loadOp.ValidationErrors != null)
    throw opEx;

// Populate the CustomerGrid with the Entities in loadOp
CustomerGrid.ItemsSource = loadOp.Entities;