c# - Don't want to Update Entity in EF 6.0 -


i have method reading data entity database, converting view model. in method, there table gets updated. result, first entity change committed database.

how can around this? way attaching orderheader entity view model? note viewmode.orderheader of type orderheader. there way denote working copy of data subsequent commit won't save these changes? need detach entity context?

public orderheaderviewmodel convertclasstoviewmodel(orderheader entity)             {                 orderheaderviewmodel viewmodel = new orderheaderviewmodel();                 viewmodel.orderheader = entity;                 viewmodel.orderheader.customerrequesteddatetime =                     managetimedetailsappserv.convertfromutcdatetime(viewmodel.orderheader.customerrequesteddatetime).value; <------ change being committed db.                 return viewmodel;             } 

fixed adding .asnotracking() repository search.

var orderhdr = _orderheaderrepository.searchfor(predicate).asnotracking().single(); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -