How to add and delete EF objects working with DataLoadMode="Asynchronous"?

2 posts, 0 answers
  1. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 11 Oct 2012 Link to this post

    For easy coding we would like to use the DataGridViews feature DataLoadMode="Asynchronous" binding directly to the query.
    Using this we do not need to manually code async EF I/O, the application does not block and by Binding the windows IsEnabled to the grids IsDirty we can easily block user input on the busy window.

    If we use an ObservableCollection the I/O happens outside of the grid and thus is not async.
    grid.ItemsSource = ObservableCollection(qry)

    Without using an ObservableCollection I cannot get adds and deletes working.
    For instance using grid.ItemsSource.Remove(grid.SelectedItem) plus db.RemoveObjet() seems not to work.

    Is there an example for this scenario somewhere?

  2. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 17 Oct 2012 Link to this post

    Because there was no answer to my question I assume the usability of DataLoadMode="Asynchronous" is limited to scenarios without ObservableCollections.

    I implemented async loading manually:
    Await Task.Factory.StartNew(
        'Local() returns a change tracked ObservableCollection
            grd.ItemsSource = _dbContext.Customers.Local
        End Sub, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext)

    And use a RadBusyIndicator around the root Grid to disable then UI - the user can still move the active Window and use other Windows of the app without limitations.
Back to Top