https://github.com/psosnicki/pgnotify-net
.NET library to easily subscribe and listen PostgreSQL Database real time notifications
https://github.com/psosnicki/pgnotify-net
dotnet pglisten pgnotify postgresql realtime
Last synced: about 2 months ago
JSON representation
.NET library to easily subscribe and listen PostgreSQL Database real time notifications
- Host: GitHub
- URL: https://github.com/psosnicki/pgnotify-net
- Owner: psosnicki
- License: mit
- Created: 2022-09-15T17:57:17.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-17T18:50:55.000Z (almost 4 years ago)
- Last Synced: 2025-07-29T16:12:57.439Z (11 months ago)
- Topics: dotnet, pglisten, pgnotify, postgresql, realtime
- Language: C#
- Homepage:
- Size: 614 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# .NET library to easily subscribe and listen PostgreSQL Database real time notifications

## Install
```
PM> Install-Package PgNotifyNet -Version 1.0.1-beta
```
## Example
[Blazor SignalR Postgresql PgNotifyNet sample application](samples/PgNotifyNet.Sample/README.md)
## Sample Code
Register in container:
```
ConfigureServices(IServicesCollection servicesCollection)
{
...
services.AddPgNotifyNet(connectionString,
o => o.Trigger (t => t.OnTable("categories").After(Change.Update, Change.Delete))
.Trigger (t => t.OnTable("users").After(Change.Insert))
...
);
```
Implement ```IHandleNotification``` and handle notification:
```
public class FooNotificationHandler : IHandleNotification
{
public async Task OnDataChanged(Category oldData,Category newData, Change change)
{
//handle data change
}
}
```
or subscribe to PgNotificationService ```OnDataChange``` event
```
public FooController(IPgNotificationService notificationService)
{
notificationService.OnDataChange += (object? sender, OnDataChangeEventArgs e) => {
//handle notification
};
}
```
## License
MIT