Table of Contents

Class DataProviderBase

Namespace
LinqToDB.DataProvider
Assembly
linq2db.dll
public abstract class DataProviderBase : IDataProvider
Inheritance
DataProviderBase
Implements
Derived
Extension Methods

Constructors

DataProviderBase(string, MappingSchema)

protected DataProviderBase(string name, MappingSchema mappingSchema)

Parameters

name string
mappingSchema MappingSchema

Fields

ReaderExpressions

public readonly ConcurrentDictionary<ReaderInfo, Expression> ReaderExpressions

Field Value

ConcurrentDictionary<ReaderInfo, Expression>

Properties

ConnectionNamespace

public abstract string? ConnectionNamespace { get; }

Property Value

string

DataReaderType

public abstract Type DataReaderType { get; }

Property Value

Type

ID

public int ID { get; }

Property Value

int

MappingSchema

public virtual MappingSchema MappingSchema { get; }

Property Value

MappingSchema

Name

public string Name { get; }

Property Value

string

OnConnectionCreated

public static Func<IDataProvider, DbConnection, DbConnection>? OnConnectionCreated { get; set; }

Property Value

Func<IDataProvider, DbConnection, DbConnection>

SqlProviderFlags

public SqlProviderFlags SqlProviderFlags { get; }

Property Value

SqlProviderFlags

SupportedTableOptions

public abstract TableOptions SupportedTableOptions { get; }

Property Value

TableOptions

TransactionsSupported

public virtual bool TransactionsSupported { get; }

Property Value

bool

Methods

BulkCopyAsync<T>(DataOptions, ITable<T>, IEnumerable<T>, CancellationToken)

public virtual Task<BulkCopyRowsCopied> BulkCopyAsync<T>(DataOptions options, ITable<T> table, IEnumerable<T> source, CancellationToken cancellationToken) where T : notnull

Parameters

options DataOptions
table ITable<T>
source IEnumerable<T>
cancellationToken CancellationToken

Returns

Task<BulkCopyRowsCopied>

Type Parameters

T

BulkCopy<T>(DataOptions, ITable<T>, IEnumerable<T>)

public virtual BulkCopyRowsCopied BulkCopy<T>(DataOptions options, ITable<T> table, IEnumerable<T> source) where T : notnull

Parameters

options DataOptions
table ITable<T>
source IEnumerable<T>

Returns

BulkCopyRowsCopied

Type Parameters

T

ClearCommandParameters(DbCommand)

public virtual void ClearCommandParameters(DbCommand command)

Parameters

command DbCommand

ConvertParameterType(Type, DbDataType)

public virtual Type ConvertParameterType(Type type, DbDataType dataType)

Parameters

type Type
dataType DbDataType

Returns

Type

CreateConnection(string)

public DbConnection CreateConnection(string connectionString)

Parameters

connectionString string

Returns

DbConnection

CreateConnectionInternal(string)

protected abstract DbConnection CreateConnectionInternal(string connectionString)

Parameters

connectionString string

Returns

DbConnection

CreateSqlBuilder(MappingSchema, DataOptions)

public abstract ISqlBuilder CreateSqlBuilder(MappingSchema mappingSchema, DataOptions dataOptions)

Parameters

mappingSchema MappingSchema
dataOptions DataOptions

Returns

ISqlBuilder

DisposeCommand(DbCommand)

public virtual void DisposeCommand(DbCommand command)

Parameters

command DbCommand

ExecuteScope(DataConnection)

Creates disposable object, which should be disposed by caller after database query execution completed. Could be used to execute provider's method with scope-specific settings, e.g. with Invariant culture to workaround incorrect culture handling in provider.

public virtual IExecutionScope? ExecuteScope(DataConnection dataConnection)

Parameters

dataConnection DataConnection

Current data connection object.

Returns

IExecutionScope

Scoped execution disposable object or null if provider doesn't need scoped configuration.

FindExpression(ReaderInfo, out Expression?)

protected bool FindExpression(ReaderInfo info, out Expression? expr)

Parameters

info ReaderInfo
expr Expression

Returns

bool

GetCommandBehavior(CommandBehavior)

public virtual CommandBehavior GetCommandBehavior(CommandBehavior commandBehavior)

Parameters

commandBehavior CommandBehavior

Returns

CommandBehavior

GetConnectionInfo(DataConnection, string)

public virtual object? GetConnectionInfo(DataConnection dataConnection, string parameterName)

Parameters

dataConnection DataConnection
parameterName string

Returns

object

GetQueryParameterNormalizer()

Returns instance of IQueryParametersNormalizer, which implements normalization logic for parameters of single query. E.g. it could include:

  • trimming names that are too long
  • removing/replacing unsupported characters
  • name deduplication for parameters with same name
. For implementation without state it is recommended to return static instance. E.g. this could be done for providers with positional parameters that ignore names.
public virtual IQueryParametersNormalizer GetQueryParameterNormalizer()

Returns

IQueryParametersNormalizer

GetReaderExpression(DbDataReader, int, Expression, Type?)

public virtual Expression GetReaderExpression(DbDataReader reader, int idx, Expression readerExpression, Type? toType)

Parameters

reader DbDataReader
idx int
readerExpression Expression
toType Type

Returns

Expression

GetSchemaProvider()

public abstract ISchemaProvider GetSchemaProvider()

Returns

ISchemaProvider

GetSqlOptimizer(DataOptions)

public abstract ISqlOptimizer GetSqlOptimizer(DataOptions dataOptions)

Parameters

dataOptions DataOptions

Returns

ISqlOptimizer

InitCommand(DataConnection, DbCommand, CommandType, string, DataParameter[]?, bool)

Initializes DataConnection command object.

public virtual DbCommand InitCommand(DataConnection dataConnection, DbCommand command, CommandType commandType, string commandText, DataParameter[]? parameters, bool withParameters)

Parameters

dataConnection DataConnection

Data connection instance to initialize with new command.

command DbCommand

Command instance to initialize.

commandType CommandType

Type of command.

commandText string

Command SQL.

parameters DataParameter[]

Optional list of parameters to add to initialized command.

withParameters bool

Flag to indicate that command has parameters. Used to configure parameters support when method called without parameters and parameters added later to command.

Returns

DbCommand

Initialized command instance.

InitContext(IDataContext)

public virtual void InitContext(IDataContext dataContext)

Parameters

dataContext IDataContext

IsDBNullAllowed(DataOptions, DbDataReader, int)

public virtual bool? IsDBNullAllowed(DataOptions options, DbDataReader reader, int idx)

Parameters

options DataOptions
reader DbDataReader
idx int

Returns

bool?

NormalizeTypeName(string?)

protected virtual string? NormalizeTypeName(string? typeName)

Parameters

typeName string

Returns

string

SetCharField(string, Expression<Func<DbDataReader, int, string>>)

protected void SetCharField(string dataTypeName, Expression<Func<DbDataReader, int, string>> expr)

Parameters

dataTypeName string
expr Expression<Func<DbDataReader, int, string>>

SetCharFieldToType<T>(string, Expression<Func<DbDataReader, int, string>>)

protected void SetCharFieldToType<T>(string dataTypeName, Expression<Func<DbDataReader, int, string>> expr)

Parameters

dataTypeName string
expr Expression<Func<DbDataReader, int, string>>

Type Parameters

T

SetField<TP, T>(Expression<Func<TP, int, T>>)

protected void SetField<TP, T>(Expression<Func<TP, int, T>> expr)

Parameters

expr Expression<Func<TP, int, T>>

Type Parameters

TP
T

SetField<TP, T>(string, Expression<Func<TP, int, T>>)

protected void SetField<TP, T>(string dataTypeName, Expression<Func<TP, int, T>> expr)

Parameters

dataTypeName string
expr Expression<Func<TP, int, T>>

Type Parameters

TP
T

SetField<TP, T>(string, Type, Expression<Func<TP, int, T>>)

protected void SetField<TP, T>(string dataTypeName, Type fieldType, Expression<Func<TP, int, T>> expr)

Parameters

dataTypeName string
fieldType Type
expr Expression<Func<TP, int, T>>

Type Parameters

TP
T

SetParameter(DataConnection, DbParameter, string, DbDataType, object?)

public virtual void SetParameter(DataConnection dataConnection, DbParameter parameter, string name, DbDataType dataType, object? value)

Parameters

dataConnection DataConnection
parameter DbParameter
name string
dataType DbDataType
value object

SetParameterType(DataConnection, DbParameter, DbDataType)

protected virtual void SetParameterType(DataConnection dataConnection, DbParameter parameter, DbDataType dataType)

Parameters

dataConnection DataConnection
parameter DbParameter
dataType DbDataType

SetProviderField<TP, T>(Expression<Func<TP, int, T>>)

protected void SetProviderField<TP, T>(Expression<Func<TP, int, T>> expr)

Parameters

expr Expression<Func<TP, int, T>>

Type Parameters

TP
T

SetProviderField<TP, T, TS>(Expression<Func<TP, int, T>>)

protected void SetProviderField<TP, T, TS>(Expression<Func<TP, int, T>> expr)

Parameters

expr Expression<Func<TP, int, T>>

Type Parameters

TP
T
TS

SetToType<TP, T, TF>(Expression<Func<TP, int, T>>)

protected void SetToType<TP, T, TF>(Expression<Func<TP, int, T>> expr)

Parameters

expr Expression<Func<TP, int, T>>

Type Parameters

TP
T
TF

SetToType<TP, T, TF>(string, Expression<Func<TP, int, T>>)

protected void SetToType<TP, T, TF>(string dataTypeName, Expression<Func<TP, int, T>> expr)

Parameters

dataTypeName string
expr Expression<Func<TP, int, T>>

Type Parameters

TP
T
TF