Reputation: 35703
i want to execute a method each time an item is added to an DbSet.
Is this possible without calling this method seperate each time?
Upvotes: 2
Views: 136
Reputation: 6191
DbSet has a property "Local
" which is an ObservableCollection
. You can subscribe to CollectionChanged
on this to see when things have been added.
So something like:
this.ttActivities.Local.CollectionChanged += ttActivitiesChanged;
public void ttActivitiesChanged(object sender, NotifyCollectionChangedEventArgs args)
{
if (args.Action == NotifyCollectionChangedAction.Add)
{
// Something has been added
}
}
Upvotes: 1