Live data - Update from database - Entity Framework 4.2 RRS feed

  • Question

  • Hi,

    I'm using the Entity Framework 4.2 and the dbContext.

    I have a datagrid (wpf) that display data from a table in my database.

    When a change is done in the database, how can I update my datagrid without any click ?

    Thank you

    Friday, January 27, 2012 4:50 PM


  • From what I know the DbContext API has only calls to update individual entities - one by one - so you will have to iterate over the entities yourself; and then you still don't know which ones have been deleted in the DB...

    Generally, if you consider all possibilities and special cases of references between entities, synchronizing the context with the DB can get very complicated which makes a general/automated approach rather difficult. You can read about the caveats and a decent workaround for simple cases here:

    • Edited by Andreas Steidle Saturday, January 28, 2012 9:00 AM
    • Marked as answer by Alan_chen Thursday, February 9, 2012 8:13 AM
    Saturday, January 28, 2012 8:40 AM

All replies