Prevent entity from saving to database upon call SaveChanges
Posted: Sun 01 Nov 2009 04:19
Is there a way to override entity framework behavior when calling SaveChanges on DBModelContext?
In following example, I would like to prevent changes in customer entity to reflect in database, but want to allow changes to products be reflected in db.
var customer = dbmodelctx.customer.where().select(c => c).first();
customer.status = "something";
var products = dbmodelctx.products.select(p=>p);
foreach (var p in products)
{
if (customer.status == "something") p.status='anything';
}
dbmodelctx.savechanges();
In following example, I would like to prevent changes in customer entity to reflect in database, but want to allow changes to products be reflected in db.
var customer = dbmodelctx.customer.where().select(c => c).first();
customer.status = "something";
var products = dbmodelctx.products.select(p=>p);
foreach (var p in products)
{
if (customer.status == "something") p.status='anything';
}
dbmodelctx.savechanges();