none
How to bind to DataGridColumn DbSet with many-to-many relationship EF 4.2 <> WPF ? RRS feed

  • Question

  • I have problem with one DataGridTextColumn that uses binding to sub DbSet with many-to-many relationship.

    When I use

    db.Configuration.LazyLoadingEnabled = true;

    binding works fine, but scrolling incredibly slow even if this column is not exists. About 10.000 rows in DataGrid. But, when

    db.Configuration.LazyLoadingEnabled = false;

     data will not appear in the column, because always  SubDbSet<Entity>.Count == 0.

    I use IValueConverter

    Sunday, February 5, 2012 11:29 AM

Answers

  • Hi silverweb;

    This line of code will not hit the database for related object, it is told not to load them.

    db.Configuration.LazyLoadingEnabled = false;

    This line of code will hit the database each time a request for related objects is made. You state that you have 10,000 rows in the data grid and this will be very slow.

    db.Configuration.LazyLoadingEnabled = true;

    My suggestion is to load the data grid with enough rows that can be displayed at one time and get new rows as the user pages through the data.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Sunday, February 5, 2012 7:59 PM