Skip to content

Commit

Permalink
Remove ValueBuffer from update pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Apr 27, 2022
1 parent 8236cb9 commit 526006e
Show file tree
Hide file tree
Showing 22 changed files with 337 additions and 527 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static readonly IDictionary<Type, ServiceCharacteristics> RelationalServi
{ typeof(IMigrationsAnnotationProvider), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IMigrationCommandExecutor), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRelationalTypeMappingSource), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRelationalValueBufferFactoryFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IUpdateSqlGenerator), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRelationalTransactionFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRelationalCommandBuilderFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
Expand Down Expand Up @@ -149,7 +148,6 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd<IMigrationsSqlGenerator, MigrationsSqlGenerator>();
TryAdd<IExecutionStrategyFactory, RelationalExecutionStrategyFactory>();
TryAdd<ITypeMappingSource>(p => p.GetRequiredService<IRelationalTypeMappingSource>());
TryAdd<IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>();
TryAdd<IDatabaseCreator>(p => p.GetRequiredService<IRelationalDatabaseCreator>());
TryAdd<IDbContextTransactionManager>(p => p.GetRequiredService<IRelationalConnection>());
TryAdd<IQueryContextFactory, RelationalQueryContextFactory>();
Expand Down Expand Up @@ -188,7 +186,6 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
.AddDependencySingleton<RelationalAnnotationProviderDependencies>()
.AddDependencySingleton<MigrationsAnnotationProviderDependencies>()
.AddDependencySingleton<ParameterNameGeneratorDependencies>()
.AddDependencySingleton<RelationalValueBufferFactoryDependencies>()
.AddDependencySingleton<RelationalTransactionFactoryDependencies>()
.AddDependencySingleton<RelationalCommandBuilderDependencies>()
.AddDependencySingleton<QuerySqlGeneratorDependencies>()
Expand Down
29 changes: 0 additions & 29 deletions src/EFCore.Relational/Storage/IRelationalValueBufferFactory.cs

This file was deleted.

This file was deleted.

This file was deleted.

36 changes: 17 additions & 19 deletions src/EFCore.Relational/Storage/RelationalTypeMapping.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Concurrent;
using System.Data;
using System.Globalization;
using Microsoft.EntityFrameworkCore.Internal;
Expand Down Expand Up @@ -225,22 +226,21 @@ public RelationalTypeMappingParameters WithComposedConverter(ValueConverter? con
private static readonly MethodInfo GetFieldValueMethod
= GetDataReaderMethod(nameof(DbDataReader.GetFieldValue));

private static readonly IDictionary<Type, MethodInfo> GetXMethods
= new Dictionary<Type, MethodInfo>
{
{ typeof(bool), GetDataReaderMethod(nameof(DbDataReader.GetBoolean)) },
{ typeof(byte), GetDataReaderMethod(nameof(DbDataReader.GetByte)) },
{ typeof(char), GetDataReaderMethod(nameof(DbDataReader.GetChar)) },
{ typeof(DateTime), GetDataReaderMethod(nameof(DbDataReader.GetDateTime)) },
{ typeof(decimal), GetDataReaderMethod(nameof(DbDataReader.GetDecimal)) },
{ typeof(double), GetDataReaderMethod(nameof(DbDataReader.GetDouble)) },
{ typeof(float), GetDataReaderMethod(nameof(DbDataReader.GetFloat)) },
{ typeof(Guid), GetDataReaderMethod(nameof(DbDataReader.GetGuid)) },
{ typeof(short), GetDataReaderMethod(nameof(DbDataReader.GetInt16)) },
{ typeof(int), GetDataReaderMethod(nameof(DbDataReader.GetInt32)) },
{ typeof(long), GetDataReaderMethod(nameof(DbDataReader.GetInt64)) },
{ typeof(string), GetDataReaderMethod(nameof(DbDataReader.GetString)) }
};
private static readonly ConcurrentDictionary<Type, MethodInfo> GetXMethods = new()
{
[typeof(bool)] = GetDataReaderMethod(nameof(DbDataReader.GetBoolean)),
[typeof(byte)] = GetDataReaderMethod(nameof(DbDataReader.GetByte)),
[typeof(char)] = GetDataReaderMethod(nameof(DbDataReader.GetChar)),
[typeof(DateTime)] = GetDataReaderMethod(nameof(DbDataReader.GetDateTime)),
[typeof(decimal)] = GetDataReaderMethod(nameof(DbDataReader.GetDecimal)),
[typeof(double)] = GetDataReaderMethod(nameof(DbDataReader.GetDouble)),
[typeof(float)] = GetDataReaderMethod(nameof(DbDataReader.GetFloat)),
[typeof(Guid)] = GetDataReaderMethod(nameof(DbDataReader.GetGuid)),
[typeof(short)] = GetDataReaderMethod(nameof(DbDataReader.GetInt16)),
[typeof(int)] = GetDataReaderMethod(nameof(DbDataReader.GetInt32)),
[typeof(long)] = GetDataReaderMethod(nameof(DbDataReader.GetInt64)),
[typeof(string)] = GetDataReaderMethod(nameof(DbDataReader.GetString))
};

private static MethodInfo GetDataReaderMethod(string name)
=> typeof(DbDataReader).GetRuntimeMethod(name, new[] { typeof(int) })!;
Expand Down Expand Up @@ -602,9 +602,7 @@ public virtual MethodInfo GetDataReaderMethod()
/// </summary>
/// <returns>The method to use to read the value.</returns>
public static MethodInfo GetDataReaderMethod(Type type)
=> GetXMethods.TryGetValue(type, out var method)
? method
: GetFieldValueMethod.MakeGenericMethod(type);
=> GetXMethods.GetOrAdd(type, static t => GetFieldValueMethod.MakeGenericMethod(t));

/// <summary>
/// Gets a custom expression tree for reading the value from the input data reader
Expand Down

This file was deleted.

Loading

0 comments on commit 526006e

Please sign in to comment.