Retrieving Entities and the MergeOption Setting
In the Entity Framework, the MergeOption setting of an object query (such as used with LINQ) specifies how entities loaded into the object context by a query are merged with entities already in the object context.
- AppendOnly - Entities that are already loaded in the object context are not retrieved from the database. When you ask for an entity already loaded into the object context, you get a copy of the cached entity object.
- OverwriteChanges - Entities are always loaded from the database. Any property values that have changed are overwritten by values from the database.
- PreserveChanges - Entities are always loaded from the database. However, any changes made to entities in the object context are preserved.
- NoTracking - Entities are maintained in a Detached state are not tracked in the Object State Manager
By default, when you retrieve entities using MM .NET Business Objects, the default value of the MergeOption is OverwriteChanges. This means that whenever you call GetEntity() or GetEntityList(), they always return new entities from the database.
If you want to change this behavior, you can change the business object's DefaultMergeOption property's value in the constructor of your project's ABusinessObject class. You can also change it for just a single business object, or you can change it dynamically at run time from one value to another.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 02/16/10
Comment or report problem with topic
