Session: How to Ignore Entity Changes
To indicate that an entity should be ignored when tracking changes,
use the advanced
session ignoreChangesFor
method.
Using Load
again to retrieve this entity will not initiate a server call.
The entity will still take part in the session, but be ignored when save_changes
is called.
Syntax
void ignoreChangesFor(Object entity);
Parameters | ||
---|---|---|
entity | Object | Instance of entity for which changes will be ignored. |
Example
Product product = session.load(Product.class, "products/1-A");
session.advanced().ignoreChangesFor(product);
product.unitsInStock++; //this will be ignored for SaveChanges
session.saveChanges();