-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from yv989c/develop
New Features
- Loading branch information
Showing
21 changed files
with
682 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<VersionEFCore3>3.8.0</VersionEFCore3> | ||
<VersionEFCore5>5.8.0</VersionEFCore5> | ||
<VersionEFCore6>6.8.0</VersionEFCore6> | ||
<VersionEFCore7>7.3.0</VersionEFCore7> | ||
<VersionEFCore3>3.9.0</VersionEFCore3> | ||
<VersionEFCore5>5.9.0</VersionEFCore5> | ||
<VersionEFCore6>6.9.0</VersionEFCore6> | ||
<VersionEFCore7>7.4.0</VersionEFCore7> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
{ | ||
internal enum EntityPropertyTypeName | ||
{ | ||
Unknown, | ||
Boolean, | ||
Byte, | ||
Int16, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/QueryableValues.SqlServer/QueryableValuesServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#if EFCORE | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using System; | ||
|
||
namespace BlazarTech.QueryableValues | ||
{ | ||
/// <summary> | ||
/// Provides extension methods to register core QueryableValues services. | ||
/// </summary> | ||
public static class QueryableValuesServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the services required by QueryableValues for the Microsoft SQL Server database provider. | ||
/// </summary> | ||
/// <remarks> | ||
/// It is only needed when building the internal service provider for use with | ||
/// the <see cref="DbContextOptionsBuilder.UseInternalServiceProvider" /> method. | ||
/// This is not recommend other than for some advanced scenarios. | ||
/// </remarks> | ||
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> | ||
/// <returns>The same service collection so that multiple calls can be chained.</returns> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static IServiceCollection AddQueryableValuesSqlServer(this IServiceCollection services) | ||
{ | ||
if (services is null) | ||
{ | ||
throw new ArgumentNullException(nameof(services)); | ||
} | ||
|
||
for (var index = services.Count - 1; index >= 0; index--) | ||
{ | ||
var descriptor = services[index]; | ||
if (descriptor.ServiceType != typeof(IModelCustomizer)) | ||
{ | ||
continue; | ||
} | ||
|
||
if (descriptor.ImplementationType is null) | ||
{ | ||
continue; | ||
} | ||
|
||
// Replace theirs with ours. | ||
services[index] = new ServiceDescriptor( | ||
descriptor.ServiceType, | ||
typeof(ModelCustomizer<>).MakeGenericType(descriptor.ImplementationType), | ||
descriptor.Lifetime | ||
); | ||
|
||
// Add theirs as is, so we can inject it into ours. | ||
services.Add( | ||
new ServiceDescriptor( | ||
descriptor.ImplementationType, | ||
descriptor.ImplementationType, | ||
descriptor.Lifetime | ||
) | ||
); | ||
} | ||
|
||
services.TryAddSingleton<Serializers.IXmlSerializer, Serializers.XmlSerializer>(); | ||
services.TryAddSingleton<Serializers.IJsonSerializer, Serializers.JsonSerializer>(); | ||
services.TryAddScoped<SqlServer.XmlQueryableFactory>(); | ||
services.TryAddScoped<SqlServer.JsonQueryableFactory>(); | ||
services.TryAddScoped<SqlServer.ExtensionOptions>(); | ||
services.TryAddScoped<SqlServer.QueryableFactoryFactory>(); | ||
services.TryAddScoped<IInterceptor, SqlServer.JsonSupportConnectionInterceptor>(); | ||
|
||
return services; | ||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.