Turn Off update for views

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
baio
Posts: 3
Joined: Mon 17 Jan 2011 15:47

Turn Off update for views

Post by baio » Tue 13 Dec 2011 07:33

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!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 13 Dec 2011 14:34

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();

Post Reply