-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
I am creating a custom DbContext class which requires a List of entities that I want to track. I want to attach tracker only to the list but the samples in documentation say that the tracker needs to be configured for the containing class as well. Here is how my code looks at the moment, which is not ideal.
public class CustomDbContextBase<T> : IUnitOfWork where T : Entity
{
public CustomDbContextBase()
{
// no op: Required for change tracking.
}
protected CustomDbContextBase(string endpointUrl, string databaseId, string masterKey, string collectionId, IMediator mediator)
{
// Initialize change tracking
var config = ObjectChangeTracking.CreateConfiguration();
config.TrackThisType<CustomDbContextBase<T>>(t => t.IncludeProperty(a => a.TrackedEntities));
var objectFactory = config.CreateTrackableObjectFactory();
this.TrackedEntities = objectFactory.CreateOf<CustomDbContextBase<T>>().TrackedEntities;
}
public virtual IList<T> TrackedEntities { get; set; }
...
}
How can I attach tracker to just the TrackedEntities list and not the CustomDbContextBase?
Reactions are currently unavailable