using (var context = new MyDbContext(),
// Get ObjectContext from DBContext
objectContext = ((IObjectContextAdapter)context).ObjectContext) {
// Construct an ObjectQuery
var customers = objectContext.CreateObjectSet<Customer>()
.Where(c => c.State == "VA").Take(2));
// Set the MergeOption property
(customers as ObjectQuery<Customer>).MergeOption =
MergeOption.OverwriteChanges;
// Do something with your data
foreach(var customer in customers) { ... }
}
Since that is a specific EF feature, there is not a built-in option for doing it via a flag or parameter. The only way I can think of is to create a custom aspect for implementing that behavior.
There are some example blog posts on this page that give examples of where you can hook in via writing custom attributes.
Hope this helps.
https://github.com/SharpRepository/SharpRepository/wiki/Hooks