c# - Query Entity Framework including records that have not been committed -


It is possible to ask a reference, make changes in one unit, and then it is possible to get the reference back and get results. Set back which contains a converted unit without including saved things? (I do not want to save because I want to rollback)

I know that I can withdraw changes using GetObjectStateEntries, but I am interested in the whole dataset .. Not only the changed institutions.

I think the only way to do this is with a savings window, but wrap around a transaction around everything so that I can do a rollback if my status is not complete. Or am I doing something easy?

Why should not the group of existing institutions be added? I tested it and it seems that works - though it does not have an account to be removed, but you should be able to get this idea:

  // Obtain those entities The ones that have been inserted or modified on projects = myObjectContext.ObjectStateManager.GetObjectStateEntries (EntityState.Added | EntityState.Modified). Where (x => x.Entity is the project) .Select (x => (project) X.Entity); // Existing institutions, those that are being modified on projects2 = myObjectContext.Projects.Where to get out (BuildDoesntContainExpression & LT; Project, Integer> (Z = & gt; z.ProjectId, projects.Select ( X => x.ProjectId))); // Union 2 set var projects 3 projects. Union (project 2);  

BuildDoesntContainExpression : You can not use it, and therefore you can not invert with EF for some reason, so use this method: < / P>

  Private static expression & lt; Funk & lt; Teleman, bull & gt; & Gt; BuildDoesntContainExpression & LT; Telement, TValue & gt; (> valueSelector, IEnumerable & lt; TValue & gt; value); if (zero == valueSelector) {New ArgumentNullException ("valueSelector") of the function & lt; } If (null == value) {New argument NullException ("value"); } Parameter Expiration p = valueSelector.Parameters.Single (); // p = & gt; Value selector (p) == value [0] || Value selector (P) == ... if (! Values.Any ()) {return e = & gt; false; } Var equals = value. Select (value => expression) expression. Zero (value selector body, expression constant (value, typef (TVL))); Var Body = Iqbal Aggregate & lt; Expression & gt; ((Accumulated, equal) => expression. And (accumulated, equal)); Return expression. Lambda & lt; Func & lt; Teleman, Ball & gt; & Gt; (Body, p); }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -