/// <summary> /// Gets an observable object for the specified entity type. /// </summary> /// <param name="policy">The detection policy that should be applied to the observable.</param> /// <typeparam name="T">The entity type.</typeparam> /// <returns>Returns the observable object that can be used to detect changes.</returns> public ReactiveDbSet <T> ObservableFor <T>(ChangeDetectionPolicy policy) where T : class { // Checks if the observable already exists, if not, adds it to the list if (!this.reactiveDbSets.ContainsKey(typeof(T))) { this.reactiveDbSets[typeof(T)] = new Dictionary <ChangeDetectionPolicy, ReactiveDbSet>(); } if (!this.reactiveDbSets[typeof(T)].ContainsKey(policy)) { this.reactiveDbSets[typeof(T)][policy] = new ReactiveDbSet <T>(this, policy); } // Returns the observable object return(this.reactiveDbSets[typeof(T)][policy] as ReactiveDbSet <T>); }
/// <summary> /// Initializes a new <see cref="DbSetObservable"/> instance. /// </summary> /// <param name="dbContext">The context for which the observable is generated.</param> /// <param name="policy">The change detection policy that should be used by the set.</param> internal ReactiveDbSet(ReactiveDbContext dbContext, ChangeDetectionPolicy policy) { this.DbContext = dbContext; this.Policy = policy; }