Table of Contents

Class SchemaProviderBase

Namespace
LinqToDB.SchemaProvider
Assembly
linq2db.dll
public abstract class SchemaProviderBase : ISchemaProvider
Inheritance
SchemaProviderBase
Implements
Derived
Extension Methods

Fields

DataTypesSchema

protected DataTable DataTypesSchema

Field Value

DataTable

ExcludedCatalogs

protected HashSet<string?> ExcludedCatalogs

Field Value

HashSet<string>

ExcludedSchemas

protected HashSet<string?> ExcludedSchemas

Field Value

HashSet<string>

GenerateChar1AsString

protected bool GenerateChar1AsString

Field Value

bool

IncludedCatalogs

protected HashSet<string?> IncludedCatalogs

Field Value

HashSet<string>

IncludedSchemas

protected HashSet<string?> IncludedSchemas

Field Value

HashSet<string>

Properties

GetProcedureSchemaExecutesProcedure

If true, provider doesn't support schema-only procedure execution and will execute procedure for real.

protected virtual bool GetProcedureSchemaExecutesProcedure { get; }

Property Value

bool

Methods

BuildProcedureParameter(ParameterSchema)

protected virtual DataParameter BuildProcedureParameter(ParameterSchema p)

Parameters

p ParameterSchema

Returns

DataParameter

BuildSchemaFilter(GetSchemaOptions?, string, Action<StringBuilder, string>)

protected string? BuildSchemaFilter(GetSchemaOptions? options, string defaultSchema, Action<StringBuilder, string> stringLiteralBuilder)

Parameters

options GetSchemaOptions
defaultSchema string
stringLiteralBuilder Action<StringBuilder, string>

Returns

string

BuildTableFunctionLoadTableSchemaCommand(ProcedureSchema, string)

Builds table function call command.

protected virtual string BuildTableFunctionLoadTableSchemaCommand(ProcedureSchema procedure, string commandText)

Parameters

procedure ProcedureSchema
commandText string

Returns

string

ForeignKeyColumnComparison(string)

protected virtual StringComparison ForeignKeyColumnComparison(string column)

Parameters

column string

Returns

StringComparison

GetColumns(DataConnection, GetSchemaOptions)

protected abstract List<ColumnInfo> GetColumns(DataConnection dataConnection, GetSchemaOptions options)

Parameters

dataConnection DataConnection
options GetSchemaOptions

Returns

List<ColumnInfo>

GetDataSourceName(DataConnection)

protected virtual string GetDataSourceName(DataConnection dbConnection)

Parameters

dbConnection DataConnection

Returns

string

GetDataType(string?, DataType?, GetSchemaOptions)

protected virtual DataTypeInfo? GetDataType(string? typeName, DataType? dataType, GetSchemaOptions options)

Parameters

typeName string
dataType DataType?
options GetSchemaOptions

Returns

DataTypeInfo

GetDataType(string?, string?, int?, int?, int?)

protected abstract DataType GetDataType(string? dataType, string? columnType, int? length, int? precision, int? scale)

Parameters

dataType string
columnType string
length int?
precision int?
scale int?

Returns

DataType

GetDataTypeByProviderDbType(int, GetSchemaOptions)

protected DataTypeInfo? GetDataTypeByProviderDbType(int typeId, GetSchemaOptions options)

Parameters

typeId int
options GetSchemaOptions

Returns

DataTypeInfo

GetDataTypes(DataConnection)

Returns list of database data types.

protected virtual List<DataTypeInfo> GetDataTypes(DataConnection dataConnection)

Parameters

dataConnection DataConnection

Database connection instance.

Returns

List<DataTypeInfo>

List of database data types.

GetDatabaseName(DataConnection)

protected virtual string GetDatabaseName(DataConnection dbConnection)

Parameters

dbConnection DataConnection

Returns

string

GetDbType(GetSchemaOptions, string?, DataTypeInfo?, int?, int?, int?, string?, string?, string?)

protected virtual string? GetDbType(GetSchemaOptions options, string? columnType, DataTypeInfo? dataType, int? length, int? precision, int? scale, string? udtCatalog, string? udtSchema, string? udtName)

Parameters

options GetSchemaOptions
columnType string
dataType DataTypeInfo
length int?
precision int?
scale int?
udtCatalog string
udtSchema string
udtName string

Returns

string

GetForeignKeys(DataConnection, IEnumerable<TableSchema>, GetSchemaOptions)

protected abstract IReadOnlyCollection<ForeignKeyInfo> GetForeignKeys(DataConnection dataConnection, IEnumerable<TableSchema> tables, GetSchemaOptions options)

Parameters

dataConnection DataConnection
tables IEnumerable<TableSchema>
options GetSchemaOptions

Returns

IReadOnlyCollection<ForeignKeyInfo>

GetHashSet(string?[]?, IEqualityComparer<string?>)

protected static HashSet<string?> GetHashSet(string?[]? data, IEqualityComparer<string?> comparer)

Parameters

data string[]
comparer IEqualityComparer<string>

Returns

HashSet<string>

GetPrimaryKeys(DataConnection, IEnumerable<TableSchema>, GetSchemaOptions)

protected abstract IReadOnlyCollection<PrimaryKeyInfo> GetPrimaryKeys(DataConnection dataConnection, IEnumerable<TableSchema> tables, GetSchemaOptions options)

Parameters

dataConnection DataConnection
tables IEnumerable<TableSchema>
options GetSchemaOptions

Returns

IReadOnlyCollection<PrimaryKeyInfo>

GetProcedureParameters(DataConnection, IEnumerable<ProcedureInfo>, GetSchemaOptions)

protected virtual List<ProcedureParameterInfo>? GetProcedureParameters(DataConnection dataConnection, IEnumerable<ProcedureInfo> procedures, GetSchemaOptions options)

Parameters

dataConnection DataConnection
procedures IEnumerable<ProcedureInfo>
options GetSchemaOptions

Returns

List<ProcedureParameterInfo>

GetProcedureResultColumns(DataTable, GetSchemaOptions)

protected virtual List<ColumnSchema> GetProcedureResultColumns(DataTable resultTable, GetSchemaOptions options)

Parameters

resultTable DataTable
options GetSchemaOptions

Returns

List<ColumnSchema>

GetProcedureSchema(DataConnection, string, CommandType, DataParameter[], GetSchemaOptions)

protected virtual DataTable? GetProcedureSchema(DataConnection dataConnection, string commandText, CommandType commandType, DataParameter[] parameters, GetSchemaOptions options)

Parameters

dataConnection DataConnection
commandText string
commandType CommandType
parameters DataParameter[]
options GetSchemaOptions

Returns

DataTable

GetProcedures(DataConnection, GetSchemaOptions)

protected virtual List<ProcedureInfo>? GetProcedures(DataConnection dataConnection, GetSchemaOptions options)

Parameters

dataConnection DataConnection
options GetSchemaOptions

Returns

List<ProcedureInfo>

GetProviderSpecificProcedures(DataConnection)

protected virtual List<ProcedureSchema>? GetProviderSpecificProcedures(DataConnection dataConnection)

Parameters

dataConnection DataConnection

Returns

List<ProcedureSchema>

GetProviderSpecificTables(DataConnection, GetSchemaOptions)

protected virtual List<TableSchema>? GetProviderSpecificTables(DataConnection dataConnection, GetSchemaOptions options)

Parameters

dataConnection DataConnection
options GetSchemaOptions

Returns

List<TableSchema>

GetProviderSpecificType(string?)

protected virtual string? GetProviderSpecificType(string? dataType)

Parameters

dataType string

Returns

string

GetProviderSpecificTypeNamespace()

protected abstract string? GetProviderSpecificTypeNamespace()

Returns

string

GetSchema(DataConnection, GetSchemaOptions?)

Returns database schema. Note that it is recommended to call this method outside of transaction as some providers do not support it or behave incorrectly. At least following providers shouldn't be called in transaction:

  • MySQL;
  • Microsoft SQL Server;
  • Sybase;
  • DB2.
public virtual DatabaseSchema GetSchema(DataConnection dataConnection, GetSchemaOptions? options = null)

Parameters

dataConnection DataConnection

Data connection to use to read schema from.

options GetSchemaOptions

Schema read configuration options.

Returns

DatabaseSchema

Returns database schema information.

GetSystemType(string?, string?, DataTypeInfo?, int?, int?, int?, GetSchemaOptions)

protected virtual Type? GetSystemType(string? dataType, string? columnType, DataTypeInfo? dataTypeInfo, int? length, int? precision, int? scale, GetSchemaOptions options)

Parameters

dataType string
columnType string
dataTypeInfo DataTypeInfo
length int?
precision int?
scale int?
options GetSchemaOptions

Returns

Type

GetTables(DataConnection, GetSchemaOptions)

protected abstract List<TableInfo> GetTables(DataConnection dataConnection, GetSchemaOptions options)

Parameters

dataConnection DataConnection
options GetSchemaOptions

Returns

List<TableInfo>

InitProvider(DataConnection)

protected virtual void InitProvider(DataConnection dataConnection)

Parameters

dataConnection DataConnection

LoadProcedureTableSchema(DataConnection, GetSchemaOptions, ProcedureSchema, string, List<TableSchema>)

protected virtual void LoadProcedureTableSchema(DataConnection dataConnection, GetSchemaOptions options, ProcedureSchema procedure, string commandText, List<TableSchema> tables)

Parameters

dataConnection DataConnection
options GetSchemaOptions
procedure ProcedureSchema
commandText string
tables List<TableSchema>

ProcessSchema(DatabaseSchema, GetSchemaOptions)

protected virtual DatabaseSchema ProcessSchema(DatabaseSchema databaseSchema, GetSchemaOptions schemaOptions)

Parameters

databaseSchema DatabaseSchema
schemaOptions GetSchemaOptions

Returns

DatabaseSchema

ToTypeName(Type?, bool)

public static string ToTypeName(Type? type, bool isNullable)

Parameters

type Type
isNullable bool

Returns

string

ToValidName(string)

public static string ToValidName(string name)

Parameters

name string

Returns

string