Important
The returned TrackingObservableCollectionT will not work if
bound to Windows Forms controls. Use ToTrackingBindingListTEntity(IEnumerableTEntity, DbContext) instead.
public static TrackingObservableCollection<TEntity> ToTrackingCollection<TEntity>(
this IEnumerable<TEntity> entities,
DbContext dataContext
)
where TEntity : class, INotifyPropertyChanged
<ExtensionAttribute>
Public Shared Function ToTrackingCollection(Of TEntity As {Class, INotifyPropertyChanged}) (
entities As IEnumerable(Of TEntity),
dataContext As DbContext
) As TrackingObservableCollection(Of TEntity)public:
[ExtensionAttribute]
generic<typename TEntity>
where TEntity : ref class, INotifyPropertyChanged
static TrackingObservableCollection<TEntity>^ ToTrackingCollection(
IEnumerable<TEntity>^ entities,
DbContext^ dataContext
)[<ExtensionAttribute>]
static member ToTrackingCollection :
entities : IEnumerable<'TEntity> *
dataContext : DbContext -> TrackingObservableCollection<'TEntity> when 'TEntity : not struct and INotifyPropertyChangedusing var dataContext = new MyDbContext();
bsAccounts.DataSource = dc.LoadAll<Account>().ToTrackingCollection(dataContext);