Skip to content

Commit fbe107c

Browse files
authored
Merge branch 'develop' into consolidateOrderBy
2 parents 995f674 + 34c910b commit fbe107c

106 files changed

Lines changed: 40522 additions & 409 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SharpRepository.EfCoreRepository/EfCoreConfigRepositoryFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ protected DbContext GetDbContext()
7474

7575
// TODO: look at dbContextType (from Enyim.Caching configuration bits) and how it caches, see about implementing cache or expanding FastActivator to take parameters
7676
DbContext dbContext = dbContextType == null
77-
? RepositoryDependencyResolver.Current?.Resolve<DbContext>()
78-
: (DbContext)RepositoryDependencyResolver.Current?.Resolve(dbContextType);
77+
? RepositoryDependencyResolver.Current?.GetService<DbContext>()
78+
: (DbContext)RepositoryDependencyResolver.Current?.GetService(dbContextType);
7979

8080
// if the Ioc container doesn't throw an error but still returns null we need to alert the consumer
8181
if (dbContext != null)
8282
{
8383
return dbContext;
8484
}
8585

86-
var options = RepositoryDependencyResolver.Current.Resolve<DbContextOptions>();
86+
var options = RepositoryDependencyResolver.Current.GetService<DbContextOptions>();
8787
if (options == null)
8888
{
8989
throw new RepositoryDependencyResolverException(typeof(DbContext));

SharpRepository.EfCoreRepository/SharpRepository.EfCoreRepository.csproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.1;netstandard2.0;netstandard1.3</TargetFrameworks>
44
<Authors>Eivind Gussiås Løkseth, Omar Piani</Authors>
55
<Description>SharpRepository generic repository implementation for Entity Framework 1.1 and 2</Description>
66
<Summary>Written in C#, includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits!</Summary>
77
<PackageId>SharpRepository.EfCoreRepository</PackageId>
8-
<PackageVersion>2.0.2.2</PackageVersion>
9-
<PackageReleaseNotes>2.0.2.1: Update to EfCore 1.1.6 and 2.1.4</PackageReleaseNotes>
8+
<PackageVersion>2.1.0-prerelease</PackageVersion>
9+
<PackageReleaseNotes>2.1.0: Support for EFCore 3.0</PackageReleaseNotes>
1010
<PackageTags>SharpRepository Repository EfCoreRepository EntityFrameworkCore Entity Framework Core 2</PackageTags>
1111
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
1212
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
1313
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
1414
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1515
<RepositoryUrl>https://github.com/SharpRepository/SharpRepository.git</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>2.0.2.1</Version>
17+
<Version>2.1.0</Version>
1818
</PropertyGroup>
1919
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
2020
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.6" />
@@ -24,7 +24,11 @@
2424
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
2525
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
2626
</ItemGroup>
27-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'netstandard2.0'">
27+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
28+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
29+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
30+
</ItemGroup>
31+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard2.1'">
2832
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
2933
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
3034
</ItemGroup>

SharpRepository.EfRepository/EfConfigRepositoryFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using SharpRepository.Repository;
55
using SharpRepository.Repository.Configuration;
66
using SharpRepository.Repository.Ioc;
7+
using ConfigurationErrorsException = SharpRepository.Repository.Configuration.ConfigurationErrorsException;
78

89
namespace SharpRepository.EfRepository
910
{
@@ -71,8 +72,8 @@ private DbContext GetDbContext()
7172
{
7273
// if there is an IOC dependency resolver configured then use that one to get the DbContext, this will allow sharing of context across multiple repositories if the IOC is configured that way
7374
return dbContextType == null
74-
? RepositoryDependencyResolver.Current.Resolve<DbContext>()
75-
: (DbContext)RepositoryDependencyResolver.Current.Resolve(dbContextType);
75+
? RepositoryDependencyResolver.Current.GetService<DbContext>()
76+
: (DbContext)RepositoryDependencyResolver.Current.GetService(dbContextType);
7677
}
7778
}
7879
}

SharpRepository.EfRepository/SharpRepository.EfRepository.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net451</TargetFramework>
4+
<TargetFrameworks>netstandard2.1;net451</TargetFrameworks>
55
<Authors>Ben Griswold, Jeff Treuting</Authors>
66
<Description>SharpRepository generic repository implemented with Entity Framework 6</Description>
77
<Summary>Written in C#, includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits!</Summary>
88
<PackageId>SharpRepository.EfRepository</PackageId>
9-
<PackageVersion>2.0.3.1</PackageVersion>
10-
<PackageReleaseNotes>2.0.3: update to Ef6.2</PackageReleaseNotes>
9+
<PackageVersion>2.1.0-prerelease</PackageVersion>
10+
<PackageReleaseNotes>2.1.0: update to EF6.3 that supports Core 3, compatibilty with generic dependency resolver</PackageReleaseNotes>
1111
<PackageTags>SharpRepository Repository EfRepository EntityFramework Entity Framework EF6</PackageTags>
1212
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
1313
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
1414
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
1515
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1616
<RepositoryUrl>https://github.com/SharpRepository/SharpRepository.git</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
18-
<Version>2.0.2</Version>
18+
<Version>2.1.0</Version>
1919
</PropertyGroup>
2020

2121
<ItemGroup>
@@ -26,7 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="EntityFramework" Version="6.2.0" />
29+
<PackageReference Include="EntityFramework" Version="6.3.0" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

SharpRepository.Ioc.Autofac/AutofacExtensions.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
using System.Collections.Generic;
33
using Autofac;
44
using Autofac.Core;
5+
using Microsoft.Extensions.Configuration;
56
using SharpRepository.Repository;
67
using SharpRepository.Repository.Configuration;
8+
using SharpRepository.Repository.Ioc;
79

810
namespace SharpRepository.Ioc.Autofac
911
{
@@ -16,9 +18,26 @@ public static class AutofacExtensions
1618
/// <param name="configuration"></param>
1719
/// <param name="repositoryName"></param>
1820
/// <param name="lifetimeScopeTag">Accepts any MatchingScopeLifetimeTags scope enum tag</param>
19-
public static void RegisterSharpRepository(this ContainerBuilder container, ISharpRepositoryConfiguration configuration, string repositoryName = null, params object[] lifetimeScopeTag)
21+
public static void RegisterSharpRepository(this ContainerBuilder containerBuilder, ISharpRepositoryConfiguration configuration, string repositoryName = null, params object[] lifetimeScopeTag)
2022
{
21-
container.RegisterSource(new RepositoryRegistrationSource(configuration, repositoryName, lifetimeScopeTag));
23+
containerBuilder.RegisterSource(new RepositoryRegistrationSource(configuration, repositoryName, lifetimeScopeTag));
24+
}
25+
26+
/// <summary>
27+
/// Registers in autofac container all IRepository and ICompoundKeyRepository resolutions.
28+
/// </summary>
29+
/// <param name="container"></param>
30+
/// <param name="configuration"></param>
31+
/// <param name="repositoryName"></param>
32+
/// <param name="lifetimeScopeTag">Accepts any MatchingScopeLifetimeTags scope enum tag</param>
33+
public static void RegisterSharpRepository(this ContainerBuilder containerBuilder, IConfigurationSection configurationSection, string repositoryName = null, params object[] lifetimeScopeTag)
34+
{
35+
if (configurationSection == null)
36+
throw new ConfigurationErrorsException("Configuration section not found.");
37+
38+
var configuration = RepositoryFactory.BuildSharpRepositoryConfiguation(configurationSection);
39+
40+
containerBuilder.RegisterSharpRepository(configuration, repositoryName, lifetimeScopeTag);
2241
}
2342
}
2443
}

SharpRepository.Ioc.Autofac/AutofacRepositoryDependencyResolver.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

SharpRepository.Ioc.Autofac/RepositoryRegistrationSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Fun
3535
typeof(ICompoundKeyRepository<,,>), typeof(ICompoundKeyRepository<,,,>), typeof(ICompoundKeyRepository<>)
3636
};
3737

38-
bool isRepositoryFunc(Type repo) => repo.GetTypeInfo().IsGenericType ? repositoryInterfaces.Contains(repo.GetGenericTypeDefinition()) : repo.GetInterfaces().Where(i => i.GetTypeInfo().IsGenericType).Select(i => i.GetGenericTypeDefinition()).Any(i => repositoryInterfaces.Contains(i));
38+
bool isRepositoryFunc(Type repo) => repo.GetTypeInfo().IsGenericType ? repositoryInterfaces.Contains(repo.GetGenericTypeDefinition()) : false;
3939
bool isCompoundRepositoryFunc(Type repo) => repo.GetTypeInfo().IsGenericType ? typeof(ICompoundKeyRepository<>) == repo.GetGenericTypeDefinition() : repo.GetInterfaces().Where(i => i.GetTypeInfo().IsGenericType).Select(i => i.GetGenericTypeDefinition()).Any(i => typeof(ICompoundKeyRepository<>) == i);
4040

4141
if (swt == null || !isRepositoryFunc(swt.ServiceType))

SharpRepository.Ioc.Autofac/SharpRepository.Ioc.Autofac.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard1.3;net451</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
44
<Authors>Ben Griswold, Jeff Treuting</Authors>
55
<Description>Configures Autofac to resolve IRepository as the right configured implementation of SharpRepository</Description>
66
<Summary>Written in C#, includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits!</Summary>
77
<PackageId>SharpRepository.Ioc.Autofac</PackageId>
8-
<PackageVersion>2.0.4.2</PackageVersion>
9-
<PackageReleaseNotes>2.0.4: registers all IRepository and ICompoundKeyRepository implementations, supports scoping</PackageReleaseNotes>
8+
<PackageVersion>2.1.0-prerelease</PackageVersion>
9+
<PackageReleaseNotes>2.1.0: DependencyResolver is IServiceProvider, local implementation of IRepository will not be resolver by container, update Autofac 4.9</PackageReleaseNotes>
1010
<PackageTags>SharpRepository Repository IoC Autofac</PackageTags>
1111
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
1212
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
1313
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
1414
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1515
<RepositoryUrl>https://github.com/SharpRepository/SharpRepository.git</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>2.0.4</Version>
17+
<Version>2.1.0</Version>
1818
</PropertyGroup>
1919
<ItemGroup>
20-
<PackageReference Include="Autofac" Version="4.8.1" />
20+
<PackageReference Include="Autofac" Version="[4.9,5.0)" />
2121
</ItemGroup>
2222
<ItemGroup>
2323
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />

SharpRepository.Ioc.Microsoft.DependencyInjection/DependencyResolverWrapper.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

SharpRepository.Ioc.Microsoft.DependencyInjection/ServicesCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static IServiceProvider UseSharpRepository(this IServiceCollection servic
3939

4040
var resolver = container.GetInstance<IServiceProvider>();
4141

42-
RepositoryDependencyResolver.SetDependencyResolver(new DependencyResolverWrapper(resolver));
42+
RepositoryDependencyResolver.SetDependencyResolver(resolver);
4343

4444
// Finally, make sure we return an IServiceProvider. This makes
4545
// ASP.NET use the StructureMap container to resolve its services.

0 commit comments

Comments
 (0)