DatabaseExtensionsToTrackingCollectionTEntity Method

This converts an enumerable list of change tracking entities to an observable collection that will notify the related data context of additions, changes, and deletions.

Definition

Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static TrackingObservableCollection<TEntity> ToTrackingCollection<TEntity>(
	this IEnumerable<TEntity> entities,
	DbContext dataContext
)
where TEntity : class, INotifyPropertyChanged

Parameters

entities  IEnumerableTEntity
An enumerable list of the entities
dataContext  DbContext
The data context that is tracking the items

Type Parameters

TEntity
The entity type

Return Value

TrackingObservableCollectionTEntity
A TrackingObservableCollectionT instance

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTEntity. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Example

C#
using var dataContext = new MyDbContext();

bsAccounts.DataSource = dc.LoadAll<Account>().ToTrackingCollection(dataContext);

See Also