DbSet<TEntity>.IListSource.GetList 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當資料綁定框架嘗試直接 DbSet<TEntity>對資料綁定時,會呼叫此方法。
System.Collections.IList IListSource.GetList();
abstract member System.ComponentModel.IListSource.GetList : unit -> System.Collections.IList
override this.System.ComponentModel.IListSource.GetList : unit -> System.Collections.IList
Function GetList () As IList Implements IListSource.GetList
傳回
從不回來,總是拋出例外。
實作
例外狀況
總是被拋出。
備註
此實作會拋出例外,因為直接綁定 will DbSet<TEntity> 時,每次資料綁定框架請求集合內容時,都會向資料庫發送查詢。 相反地,先將結果載入上下文,例如使用Load<TSource>(IQueryable<TSource>)擴充方法,然後透過呼叫 ToObservableCollection() (by)Local以 WPF 綁定ToBindingList()或 WinForms 綁定本地資料。
更多資訊與範例請參閱 EF Core中追蹤實體的本地視圖 。