DbSet<TEntity>.IListSource.GetList Method

Definition

This method is called by data binding frameworks when attempting to data bind directly to a 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

Returns

Never returns, always throws an exception.

Implements

Exceptions

Always thrown.

Remarks

This implementation always throws an exception as binding directly to a DbSet<TEntity> will result in a query being sent to the database every time the data binding framework requests the contents of the collection. Instead load the results into the context, for example, by using the Load<TSource>(IQueryable<TSource>) extension method, and then bind to the local data through the Local by calling ToObservableCollection() for WPF binding, or ToBindingList() for WinForms.

See Local views of tracked entities in EF Core for more information and examples.

Applies to