DbSet.Load() function missing in EF 6.0

后端 未结 4 881
名媛妹妹
名媛妹妹 2021-02-12 02:52

I am trying to access the DbSet.Load() function to load the entities. This function no longer exists in EF 6.0; upon certain investigation I foun

相关标签:
4条回答
  • 2021-02-12 03:03

    Also, besides System.Data.Entity, you must add the System.Linq namespace as well as System.Windows.

    0 讨论(0)
  • 2021-02-12 03:12

    I found I needed to add:

    using System.Data.Entity;
    
    0 讨论(0)
  • 2021-02-12 03:13

    DbSet.ToList() will return all items from given set, and will populate the DbSet.Local property. You can call either ToList() or Load(). You do not need to reference Local property though, you could create manually ObservableCollection.

    return new ObservbableCollection<Customer>(DataBaseContext.Set<Customer>().ToList());
    

    There could be a difference between the ToList() and Local. If for example, this is not the first time you are executing a query on the customer set, Local could contain data that is invalid, if the data was deleted on the network.

    0 讨论(0)
  • 2021-02-12 03:17

    In EF6 the class containing extension methods was renamed from DbQueryExtensions to QueryableExtensions but the .Load() method is still there. If you are not calling this extension method directly the rename should not matter to you.

    0 讨论(0)
提交回复
热议问题