https://github.com/stoveproject/Stove
Domain Driven Design oriented application framework, meets CRUD needs
https://github.com/stoveproject/Stove
cqrs dapper dbcontext ddd domain-driven-design entity-framework framework hangfire nhibernate nlog rabbitmq ravendb redis stove transaction
Last synced: 9 days ago
JSON representation
Domain Driven Design oriented application framework, meets CRUD needs
- Host: GitHub
- URL: https://github.com/stoveproject/Stove
- Owner: stoveproject
- License: mit
- Archived: true
- Created: 2016-12-30T10:32:05.000Z (about 9 years ago)
- Default Branch: dev
- Last Pushed: 2018-12-11T21:05:54.000Z (about 7 years ago)
- Last Synced: 2026-01-14T05:09:54.810Z (13 days ago)
- Topics: cqrs, dapper, dbcontext, ddd, domain-driven-design, entity-framework, framework, hangfire, nhibernate, nlog, rabbitmq, ravendb, redis, stove, transaction
- Language: C#
- Homepage:
- Size: 15.4 MB
- Stars: 165
- Watchers: 24
- Forks: 37
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stove [](https://ci.appveyor.com/project/osoykan/stove-jo52k)
|Package|Status|
|:------|:-----:|
|Stove|[](https://badge.fury.io/nu/Stove)|
|Stove.Entityframework|[](https://badge.fury.io/nu/Stove.EntityFramework)|
|Stove.EntityframeworkCore|[](https://badge.fury.io/nu/Stove.EntityFrameworkCore)|
|Stove.Hangfire|[](https://badge.fury.io/nu/Stove.Hangfire)|
|Stove.NLog|[](https://badge.fury.io/nu/Stove.NLog)|
|Stove.Serilog|[](https://badge.fury.io/nu/Stove.Serilog)|
|Stove.Mapster|[](https://badge.fury.io/nu/Stove.Mapster)|
|Stove.Redis|[](https://badge.fury.io/nu/Stove.Redis)|
|Stove.Dapper|[](https://badge.fury.io/nu/Stove.Dapper)|
|Stove.RabbitMQ|[](https://badge.fury.io/nu/Stove.RabbitMQ)|
|Stove.NHibernate|[](https://badge.fury.io/nu/Stove.NHibernate)|
|Stove.RavenDB|[](https://badge.fury.io/nu/Stove.RavenDB)|
|Stove.Couchbase|[](https://badge.fury.io/nu/Stove.Couchbase)|
Stove is an application framework that wraps and abstracts your needs for easy use. Built with strongly adopted dependency injection principles.
## IoC
* Autofac
* Conventional Registration Mechanism with [Autofac.Extras.IocManager](https://github.com/osoykan/Autofac.Extras.IocManager)
## Use-Case & Transaction approach
* AsyncLocal Unit Of Work pattern
## Adopted principles
* Domain Driven Design
* Persistence agnosticism with **IRepository<T>**
* EventBus for DDD use cases
## Persistence Support
* EntityFramework
* EntityFramework Core
* NHibernate
## Transactional structure
|Tool|Supports Multiple Database/Session Control inside one UOW|
|:------|:-----:|
|EntityFramework| :white_check_mark: |
|EntityFrameworkCore| :white_check_mark: |
|NHibernate| :white_check_mark: |
|Dapper| :white_check_mark: |
### Notes
* To work with Dapper, you must use EF & EF Core or NHibernate as primary ORM choice. Dapper shares their transactions to execute its sqls inside of one **Unit Of Work** scope.
* **Dapper-EntityFramework**, **Dapper-NHibernate** or **Dapper-EntityFrameworkCore** works under same transaction and unit of work scope, if any exception appears in domain **whole transaction will be rollback**, including Dapper's insert/deletes or EF's or NH's.
* Stove.Dapper supports **Dynamic Filters** to filter automatically and default ISoftDelete or other user defined filters.
* NHibernate **supports multiple database** in one UOW scope.
### Nhibernate Multiple Database
Let's assume that we have two entities which are inherited from **Entity<int>**. If we want to work with multiple database with NHibernate we have to tell to Stove that which entities belong to which database or session. To achive that Stove has to know your database distinction. Basically `StoveSessionContext` does that.
#### StoveSessionContext
```csharp
public class PrimaryStoveSessionContext : StoveSessionContext
{
public IStoveSessionSet Products { get; set; }
}
```
```csharp
public class SecondaryStoveSessionContext : StoveSessionContext
{
public IStoveSessionSet Categories { get; set; }
}
```
Registration:
```csharp
builder
.UseStoveNHibernate(nhConfiguration =>
{
nhConfiguration.AddFluentConfigurationFor(() =>
{
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.ExposeConfiguration(cfg => new SchemaExport(cfg).Execute(true, true, false, _connection, Console.Out));
});
nhConfiguration.AddFluentConfigurationFor(() =>
{
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.ExposeConfiguration(cfg => new SchemaExport(cfg).Execute(true, true, false, _connection, Console.Out));
});
return nhConfiguration;
})
```
After this definition, we have to define which SessionContext uses which connection string for connect to database and creating session factory.
```csharp
[DependsOn(
typeof(StoveNHibernateBootstrapper)
)]
public class StoveNHibernateTestBootstrapper : StoveBootstrapper
{
public override void PreStart()
{
StoveConfiguration.DefaultNameOrConnectionString = "data source=:memory:";
StoveConfiguration.TypedConnectionStrings.Add(typeof(PrimaryStoveSessionContext),StoveConfiguration.DefaultNameOrConnectionString);
StoveConfiguration.TypedConnectionStrings.Add(typeof(SecondaryStoveSessionContext),StoveConfiguration.DefaultNameOrConnectionString);
DapperExtensions.DapperExtensions.SqlDialect = new SqliteDialect();
DapperExtensions.DapperExtensions.SetMappingAssemblies(new List { Assembly.GetExecutingAssembly() });
}
}
```
As you see connection strings are same but they are inside of different **StoveSessionContexts**. If these entities are inside of same database but you want to treat as different bounded contexts to them, you can choose this kind of approach for your sessions. Otherwise entities can sit together in one **SessionContext**.
Usage is always same and persistence agnostic:
```csharp
using (IUnitOfWorkCompleteHandle uow = The().Begin())
{
The>().GetAll().Count().ShouldBe(1);
The>().GetAll().Count().ShouldBe(1);
uow.Complete();
}
```
## Document Databases
* RavenDB -> **IRepository<T>**
* Couchbase -> **IRepository<T>**
## Queue Mechanism
* RabbitMQ support
## Background Jobs
* HangFire support
## Caching
* Redis support
## Others
* A lot of extensions
* Strictly **SOLID**
## Composition Root
```csharp
IRootResolver resolver = IocBuilder.New
.UseAutofacContainerBuilder()
.UseStove(autoUnitOfWorkInterceptionEnabled: true)
.UseStoveEntityFramework()
.UseStoveDapper()
.UseStoveMapster()
.UseStoveDefaultEventBus()
.UseStoveDbContextEfTransactionStrategy()
.UseStoveTypedConnectionStringResolver()
.UseStoveNLog()
.UseStoveBackgroundJobs()
.UseStoveRedisCaching()
.UseStoveRabbitMQ(configuration =>
{
configuration.HostAddress = "rabbitmq://localhost/";
configuration.Username = "admin";
configuration.Password = "admin";
configuration.QueueName = "Default";
return configuration;
})
.UseStoveHangfire(configuration =>
{
configuration.GlobalConfiguration
.UseSqlServerStorage("Default")
.UseNLogLogProvider();
return configuration;
})
.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()))
.CreateResolver();
var someDomainService = resolver.Resolve();
someDomainService.DoSomeStuff();
```