Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Entity framework -Undo changes takes a very long time

Entity framework -Undo changes takes a very long time

Scheduled Pinned Locked Moved Visual Basic
databasesysadmincsharpsql-server
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    desanti
    wrote on last edited by
    #1

    Hello ! I'm using vb.net 2017 with EF 6 and Sql server 2008R2. On my form I have a bindingsource bound to entity.also I have a datagridview that has Mybindingsource as datasource. I have a save button and a Undo button.So the user make changes and can press the save button to save the data on database and Undo button to undo the changes. For the Undo button I have this code :

    For it = MyBindingSource.Count - 1 To 0 Step -1
    Dim entry As Infrastructure.DbEntityEntry = context.Entry(MyBindingSource.Item(it))
    Select Case entry.State
    Case 1
    entry.State = EntityState.Detached
    MyBindingSource.Remove(MyBindingSource.Item(it))
    Case EntityState.Modified
    entry.CurrentValues.SetValues(entry.OriginalValues)
    entry.State = EntityState.Unchanged
    Case EntityState.Deleted
    entry.State = EntityState.Modified
    entry.CurrentValues.SetValues(entry.OriginalValues)
    entry.State = EntityState.Unchanged
    End Select
    Next

    this code is working correctly , but I have noticed that when Mybindingsource has large data , for example 2300 that i'm testing now , this code needs 2-3 minutes to be executed. What can I do ? Thank you !

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups