Page 1 of 1
Turn Off update for views
Posted: Tue 13 Dec 2011 07:33
by baio
Hi! I have entity in model, this enity is mapped to the view. Is there exist some way to turn off CUD opertions for the entity. I mean - when model is updated via save() and there is some modifyed items of such entity, they won't update.
Thanks!
Posted: Tue 13 Dec 2011 14:34
by Shalex
baio wrote:Is there exist some way to turn off CUD opertions for the entity.
If you want the changes not to be sent to the database, don't change objects in your code. If objects are changed for some reason, you can turn off change tracking explicitly:
Code: Select all
Entities ctx = new Entities();
var query = ctx.Categories.Where(c => c.CategoryName.StartsWith("..."));
(query as ObjectQuery).MergeOption = MergeOption.NoTracking;
var result = query.ToList();