Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #19 from osoykan/dev
Browse files Browse the repository at this point in the history
dev to master
  • Loading branch information
osoykan authored Feb 27, 2017
2 parents 77cc8e8 + 03ca29f commit 7076ab8
Show file tree
Hide file tree
Showing 96 changed files with 2,368 additions and 430 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@
* EventBus for DDD use cases
* EntityFramework
* Generic Repository Pattern, DbContext, Multiple DbContext control in one unit of work, TransactionScope support

* Dapper and EF both can use in one application.
* Dapper and EF have their own repositories. `IDapperRepository<Product>`, `IRepository<Product>`
* Dapper-EntityFramework 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 and EF's.
* RabbitMQ support
* HangFire support
* Redis support
* A lot of extensions
* Strictly **SOLID**

## Composition Root
```csharp
IRootResolver resolver = IocBuilder.New
.UseAutofacContainerBuilder()
.UseStove(starterBootstrapperType: typeof(StoveDemoBootstrapper), autoUnitOfWorkInterceptionEnabled: true)
.UseStove<StoveDemoBootstrapper>(autoUnitOfWorkInterceptionEnabled: true)
.UseStoveEntityFramework()
.UseStoveDapper()
.UseStoveMapster()
Expand All @@ -40,6 +47,14 @@ IRootResolver resolver = IocBuilder.New
.UseStoveNLog()
.UseStoveBackgroundJobs()
.UseStoveRedisCaching()
.UseStoveRabbitMQ(configuration =>
{
configuration.HostAddress = "rabbitmq://localhost/";
configuration.Username = "admin";
configuration.Password = "admin";
configuration.QueueName = "Default";
return configuration;
})
.UseStoveHangfire(configuration =>
{
configuration.GlobalConfiguration
Expand All @@ -50,4 +65,9 @@ IRootResolver resolver = IocBuilder.New
.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()))
.CreateResolver();

var someDomainService = resolver.Resolve<SomeDomainService>();
someDomainService.DoSomeStuff();

```

## It will be documented in detail!
14 changes: 14 additions & 0 deletions Stove.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Redis", "src\Stove.Re
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.RabbitMQ", "src\Stove.RabbitMQ\Stove.RabbitMQ.xproj", "{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.RabbitMQ.Tests", "test\Stove.RabbitMQ.Tests\Stove.RabbitMQ.Tests.xproj", "{F024076F-A7AA-4B54-9F01-D3691A8BC988}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Mapster.Tests", "test\Stove.Mapster.Tests\Stove.Mapster.Tests.xproj", "{7182FAE3-631D-4485-AF40-69D60A8BD8B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -96,6 +100,14 @@ Global
{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B}.Release|Any CPU.Build.0 = Release|Any CPU
{F024076F-A7AA-4B54-9F01-D3691A8BC988}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F024076F-A7AA-4B54-9F01-D3691A8BC988}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F024076F-A7AA-4B54-9F01-D3691A8BC988}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F024076F-A7AA-4B54-9F01-D3691A8BC988}.Release|Any CPU.Build.0 = Release|Any CPU
{7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -114,5 +126,7 @@ Global
{0213E41B-70C4-4E53-89ED-70A1753CAF4B} = {23CB5044-8ECE-4DDC-89E0-FC1B8EC9DDDF}
{555DA8DA-3F03-4943-B6E3-C3ED8D258969} = {23CB5044-8ECE-4DDC-89E0-FC1B8EC9DDDF}
{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B} = {23CB5044-8ECE-4DDC-89E0-FC1B8EC9DDDF}
{F024076F-A7AA-4B54-9F01-D3691A8BC988} = {4D2BAE52-1E23-4321-BBE6-2BAC28F7B389}
{7182FAE3-631D-4485-AF40-69D60A8BD8B7} = {4D2BAE52-1E23-4321-BBE6-2BAC28F7B389}
EndGlobalSection
EndGlobal
15 changes: 10 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: 1.0.{build}
branches:
only:
- master
pull_requests:
do_not_increment_build_number: true
before_build:
- cmd: dotnet.exe restore
assembly_info:
Expand Down Expand Up @@ -31,10 +30,16 @@ after_build:

test:
assemblies:
- test\Stove.EntityFramework.Tests\bin\Debug\net452\win7-x64\Stove.EntityFramework.Tests.dll
- test\Stove.Tests\bin\Debug\net452\win7-x64\Stove.Tests.dll
- test\Stove.EntityFramework.Tests\bin\Debug\net461\win7-x64\Stove.EntityFramework.Tests.dll
- test\Stove.Mapster.Tests\bin\Debug\net461\win7-x64\Stove.Mapster.Tests.dll
- test\Stove.RabbitMQ.Tests\bin\Debug\net461\win7-x64\Stove.RabbitMQ.Tests.dll
- test\Stove.Tests\bin\Debug\net461\win7-x64\Stove.Tests.dll
- test\Stove.Tests.SampleApplication\bin\Debug\net461\win7-x64\Stove.Tests.SampleApplication.dll

deploy:
- provider: NuGet
on:
branch: master
api_key:
secure: liSTqN52OJQy9fZJk6gubSgYBAy4EXcEPCDSCLJ/3T9cZufzpTwvBlGPLX+iP2n9
artifacts:
Expand Down
6 changes: 2 additions & 4 deletions src/Stove.Dapper/Dapper/DapperAutoRepositoryTypes.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
using Stove.Dapper.Dapper.Repositories;
using Stove.Domain.Repositories;
using Stove.EntityFramework.EntityFramework;

namespace Stove.Dapper.Dapper
{
public static class DapperAutoRepositoryTypes
{
static DapperAutoRepositoryTypes()
{
Default = new AutoRepositoryTypesAttribute(
Default = new DapperAutoRepositoryTypeAttribute(
typeof(IDapperRepository<>),
typeof(IDapperRepository<,>),
typeof(DapperRepositoryBase<,>),
typeof(DapperRepositoryBase<,,>)
);
}

public static AutoRepositoryTypesAttribute Default { get; private set; }
public static DapperAutoRepositoryTypeAttribute Default { get; private set; }
}
}
2 changes: 1 addition & 1 deletion src/Stove.Dapper/Dapper/DapperRepositoryRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class DapperRepositoryRegistrar
{
public static void RegisterRepositories(Type dbContextType, IIocBuilder builder)
{
AutoRepositoryTypesAttribute autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>() ??
AutoRepositoryTypesAttribute autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<DapperAutoRepositoryTypeAttribute>() ??
DapperAutoRepositoryTypes.Default;

foreach (EntityTypeInfo entityTypeInfo in DbContextHelper.GetEntityTypeInfos(dbContextType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
}

// this is a PropertyExpression but as it's internal, to use, we cast to the base MemberExpression instead (see http://social.msdn.microsoft.com/Forums/en-US/ab528f6a-a60e-4af6-bf31-d58e3f373356/resolving-propertyexpressions-and-fieldexpressions-in-a-custom-linq-provider)
_processedProperty = node.Object;
_processedProperty = node.Object;
var me = _processedProperty as MemberExpression;

AddField(me, op, arg, _unarySpecified);
Expand Down
30 changes: 30 additions & 0 deletions src/Stove.Dapper/Dapper/Extensions/SortingExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;

using DapperExtensions;

using JetBrains.Annotations;

namespace Stove.Dapper.Dapper.Extensions
{
internal static class SortingExtensions
{
[NotNull]
public static List<ISort> ToSortable<T>([NotNull] this Expression<Func<T, object>>[] sortingExpression, bool ascending = true)
{
Check.NotNullOrEmpty(sortingExpression, nameof(sortingExpression));

var sortList = new List<ISort>();
sortingExpression.ToList().ForEach(sortExpression =>
{
MemberInfo sortProperty = ReflectionHelper.GetProperty(sortExpression);
sortList.Add(new Sort { Ascending = ascending, PropertyName = sortProperty.Name });
});

return sortList;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Data.Entity;

using Stove.Domain.Entities;
using Stove.Domain.Repositories;
using Stove.EntityFramework.EntityFramework;

namespace Stove.Dapper.Dapper.Repositories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using DapperExtensions;

using Stove.Dapper.Dapper.Expressions;
using Stove.Dapper.Dapper.Extensions;
using Stove.Domain.Entities;
using Stove.Domain.Repositories;
using Stove.Domain.Uow;
using Stove.EntityFramework.EntityFramework;

Expand Down Expand Up @@ -232,5 +232,40 @@ public override Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate)
{
return Connection.CountAsync<TEntity>(predicate.ToPredicateGroup<TEntity, TPrimaryKey>(), ActiveTransaction);
}

public override IEnumerable<TEntity> GetListPaged(Expression<Func<TEntity, bool>> predicate, int pageNumber, int itemsPerPage, bool ascending = true, params Expression<Func<TEntity, object>>[] sortingExpression)
{
return Connection.GetPage<TEntity>(predicate.ToPredicateGroup<TEntity, TPrimaryKey>(), sortingExpression.ToSortable(ascending), pageNumber, itemsPerPage, ActiveTransaction);
}

public override IEnumerable<TEntity> GetSet(Expression<Func<TEntity, bool>> predicate, int firstResult, int maxResults, bool ascending = true, params Expression<Func<TEntity, object>>[] sortingExpression)
{
return Connection.GetSet<TEntity>(predicate.ToPredicateGroup<TEntity, TPrimaryKey>(), sortingExpression.ToSortable(ascending), firstResult, maxResults, ActiveTransaction);
}

public override void Insert(TEntity entity)
{
Connection.Insert(entity, ActiveTransaction);
}

public override void Update(TEntity entity)
{
Connection.Update(entity, ActiveTransaction);
}

public override void Delete(TEntity entity)
{
Connection.Delete(entity, ActiveTransaction);
}

public override void Delete(Expression<Func<TEntity, bool>> predicate)
{
Connection.Delete(predicate.ToPredicateGroup<TEntity, TPrimaryKey>(), ActiveTransaction);
}

public override TPrimaryKey InsertAndGetId(TEntity entity)
{
return Connection.Insert(entity, ActiveTransaction);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Stove.Domain.Entities;

namespace Stove.Domain.Repositories
namespace Stove.Dapper.Dapper.Repositories
{
public interface IDapperRepository<TEntity> : IDapperRepository<TEntity, int> where TEntity : class, IEntity<int>
{
Expand Down
Loading

0 comments on commit 7076ab8

Please sign in to comment.