Home > Net > EF with edit data successfully, then refresh the page does not change
EF with edit data successfully, then refresh the page does not change
Time:11-18
EF with edit data successfully, then refresh the page does not change, tracking EF generated SQL statements, the SQL data is changed, then look at the data returned in vs do not change, very depressed, Delete and add can be updated immediately, is editing, code show warrior
Public int the Modify (T model1, params string [] paraName) { Int iret=1; Using (DbContext DB=new DBContextFactory () GetDbContext ()) { DB. Set (). The Attach (model1);
DbEntityEntry entry=DB. Entry (model1); Entry. The State=System. Data. The Entity. EntityState. Unchanged;
The foreach (string proName in paraName) { Entry. The Property (proName). IsModified=true; } Iret=the SaveChanges (); }
}
Database has been changed, unless it is running system, the query can be seen, or remove the USING, then every query a NEW context, the updated query no problem, is there a better solution, or am I wrong there
CodePudding user response:
Entry. The State=System. Data. The Entity. EntityState. Unchanged; Change to be Modified?