DbSet.Load() function missing in EF 6.0

后端 未结 4 884
名媛妹妹
名媛妹妹 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: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(DataBaseContext.Set().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.

提交回复
热议问题