forked from CirrusRedOrg/EntityFrameworkCore.Jet
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJetServiceCollectionExtensions.cs
More file actions
81 lines (76 loc) · 4.71 KB
/
Copy pathJetServiceCollectionExtensions.cs
File metadata and controls
81 lines (76 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using EntityFrameworkCore.Jet.Diagnostics.Internal;
using EntityFrameworkCore.Jet.Infrastructure.Internal;
using EntityFrameworkCore.Jet.Internal;
using EntityFrameworkCore.Jet.Metadata.Internal;
using EntityFrameworkCore.Jet.Migrations.Internal;
using EntityFrameworkCore.Jet.Query;
using EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal;
using EntityFrameworkCore.Jet.Query.Internal;
using EntityFrameworkCore.Jet.Query.Sql.Internal;
using EntityFrameworkCore.Jet.Storage.Internal;
using EntityFrameworkCore.Jet.Update.Internal;
using EntityFrameworkCore.Jet.ValueGeneration.Internal;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Update;
using EntityFrameworkCore.Jet.Utilities;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using Microsoft.EntityFrameworkCore.ValueGeneration;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Jet specific extension methods for <see cref="IServiceCollection" />.
/// </summary>
public static class JetServiceCollectionExtensions
{
public static IServiceCollection AddEntityFrameworkJet([NotNull] this IServiceCollection serviceCollection)
{
Check.NotNull(serviceCollection, nameof(serviceCollection));
var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
.TryAdd<LoggingDefinitions, JetLoggingDefinitions>()
.TryAdd<IDatabaseProvider, DatabaseProvider<JetOptionsExtension>>()
.TryAdd<IRelationalTypeMappingSource, JetTypeMappingSource>()
.TryAdd<ISqlGenerationHelper, JetSqlGenerationHelper>()
.TryAdd<IRelationalAnnotationProvider, JetAnnotationProvider>()
.TryAdd<IMigrationsAnnotationProvider, JetMigrationsAnnotationProvider>()
.TryAdd<IModelValidator, JetModelValidator>()
.TryAdd<IProviderConventionSetBuilder, JetConventionSetBuilder>()
.TryAdd<IUpdateSqlGenerator>(p => p.GetRequiredService<IJetUpdateSqlGenerator>())
.TryAdd<IModificationCommandBatchFactory, JetModificationCommandBatchFactory>()
.TryAdd<IValueGeneratorSelector, JetValueGeneratorSelector>()
.TryAdd<IRelationalConnection>(p => p.GetRequiredService<IJetRelationalConnection>())
.TryAdd<IMigrationsSqlGenerator, JetMigrationsSqlGenerator>()
.TryAdd<IRelationalDatabaseCreator, JetDatabaseCreator>()
.TryAdd<IMigrationCommandExecutor, JetMigrationCommandExecutor>()
.TryAdd<IHistoryRepository, JetHistoryRepository>()
.TryAdd<ICompiledQueryCacheKeyGenerator, JetCompiledQueryCacheKeyGenerator>()
.TryAdd<IExecutionStrategyFactory, JetExecutionStrategyFactory>()
.TryAdd<ISingletonOptions, IJetOptions>(p => p.GetRequiredService<IJetOptions>())
.TryAdd<IQueryCompilationContextFactory, JetQueryCompilationContextFactory>()
.TryAdd<IMethodCallTranslatorProvider, JetMethodCallTranslatorProvider>()
.TryAdd<IMemberTranslatorProvider, JetMemberTranslatorProvider>()
.TryAdd<IQuerySqlGeneratorFactory, JetQuerySqlGeneratorFactory>()
.TryAdd<IRelationalSqlTranslatingExpressionVisitorFactory, JetSqlTranslatingExpressionVisitorFactory>()
.TryAdd<ISqlExpressionFactory, JetSqlExpressionFactory>()
.TryAdd<IQueryTranslationPostprocessorFactory, JetQueryTranslationPostprocessorFactory>()
.TryAdd<IRelationalTransactionFactory, JetTransactionFactory>()
.TryAdd<IRelationalParameterBasedSqlProcessorFactory, JetParameterBasedSqlProcessorFactory>()
.TryAdd<IQueryableMethodTranslatingExpressionVisitorFactory, JetQueryableMethodTranslatingExpressionVisitorFactory>()
.TryAddProviderSpecificServices(
b => b
.TryAddSingleton<IJetOptions, JetOptions>()
.TryAddSingleton<IJetUpdateSqlGenerator, JetUpdateSqlGenerator>()
.TryAddScoped<IJetRelationalConnection, JetRelationalConnection>());
builder.TryAddCoreServices();
return serviceCollection;
}
}
}