c# Programming Glossary: savechanges
Soft Delete Entity Framework Code First http://stackoverflow.com/questions/12698793/soft-delete-entity-framework-code-first So I am using Entity Framework Code First I overrode SaveChanges in DbContext to allow me to do a soft delete if item.State.. Block m.Requires IsDeleted .HasValue false Override SaveChanges and find all the entries to be deleted Edit Another way to override.. the stored procedures generated by EF6 public override int SaveChanges foreach var entry in ChangeTracker.Entries .Where p p.State..
Entity Framework 4 - AddObject vs Attach http://stackoverflow.com/questions/3920111/entity-framework-4-addobject-vs-attach Person Name Joe Bloggs ctx.Persons.AddObject newPerson ctx.SaveChanges If i'm modifying an existing Person i do this var ctx new MyEntities.. p p.Name Joe Bloggs existingPerson.Name Joe Briggs ctx.SaveChanges Keep in mind this is a very simple example. In reality i am.. deal with ctx.Persons and Unit of Work don't deal with ctx.SaveChanges . But under the covers the above is what happens in my implementation...
Does Entity Framework 4 Code First have support for identity generators like NHibernate? http://stackoverflow.com/questions/5275306/does-entity-framework-4-code-first-have-support-for-identity-generators-like-nhi want client side Id generator you will have to override SaveChanges in derived DbContext and implement your own logic of assigning.. Other mapping public override int SaveChanges foreach var entry in ChangeTracker.Entries MyEntity .Where.. I'm using just static field entry.Entity.Id i return base.SaveChanges public class MyEntity public int Id get set Other properties..
Fastest Way of Inserting in Entity Framework http://stackoverflow.com/questions/5940225/fastest-way-of-inserting-in-entity-framework each record ... That's the worst thing you can do Calling SaveChanges for each record slows bulk inserts extremely down. I would do.. tests which will very likely improve the performance Call SaveChanges once after ALL records. Call SaveChanges after for example 100.. performance Call SaveChanges once after ALL records. Call SaveChanges after for example 100 records. Call SaveChanges after for example..
Entity Framework - Using Transactions or SaveChanges(false) and AcceptAllChanges()? http://stackoverflow.com/questions/815586/entity-framework-using-transactions-or-savechangesfalse-and-acceptallchanges Framework Using Transactions or SaveChanges false and AcceptAllChanges I have been investigating transactions.. take care of themselves in EF as long as I pass false to SaveChanges and then call AcceptAllChanges if there are no errors SaveChanges.. and then call AcceptAllChanges if there are no errors SaveChanges false ... AcceptAllChanges What if something goes bad don't..
|