EntityFramework.Rx
EntityFramework.Rx copied to clipboard
Reactive extension wrappers for *hot* observables of Entity Framework
EntityFramework.Rx
Reactive extension wrappers for hot observables of Entity Framework entities.
This repo contains the code for both the EntityFramework
and EntityFrameworkCore
projects.
Installation
Simply install the NuGet package for EF6 or EF Core
EF version | .NET support | NuGet package |
---|---|---|
6.1.3 | >= 4.6.1 | |
Core 2.0 | >= 4.6.1 || >= Standard 2.0 |
Usage
DbObservable
contains methods for each event type supported, which return an IObservable.
- FromInserting
- FromInsertFailed
- FromInserted
- FromUpdating
- FromUpdated
- FromUpdateFailed
- FromDeleting
- FromDeleted
- FromDeleteFailed
var birthdayMessage = DbObservable<Context>.FromInserted<Person>()
.Where(x => x.Entity.DateOfBirth.Month == DateTime.Today.Month
&& x.Entity.DateOfBirth.Day == DateTime.Today.Day)
.Subscribe(entry => Console.WriteLine($"Happy birthday to {entry.Entity.Name}!"));
Remarks
Specifying a DbContext type with DbObservable<T>
will contrain events to entities in a DbContext instance of that type.
Events provided by this library and the library which supports it (EntityFramework.Triggers) are co-variant. You can use a base class as T
in DbObservable<T>
and the events will be raised as expected.
Contributing
- Create an issue
- Let's find some point of agreement on your suggestion.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
History
License
MIT License