Table of Contents

Class DataExtensions

Namespace
LinqToDB
Assembly
linq2db.dll

Data context extension methods.

public static class DataExtensions
Inheritance
DataExtensions

Fields

SelectQueryMethodInfo

public static MethodInfo SelectQueryMethodInfo

Field Value

MethodInfo

Methods

Compile<TDc, TResult>(IDataContext, Expression<Func<TDc, TResult>>)

Compiles the query.

public static Func<TDc, TResult> Compile<TDc, TResult>(this IDataContext dataContext, Expression<Func<TDc, TResult>> query) where TDc : IDataContext

Parameters

dataContext IDataContext

Data connection context.

query Expression<Func<TDc, TResult>>

The query expression to be compiled.

Returns

Func<TDc, TResult>

A generic delegate that represents the compiled query.

Type Parameters

TDc

Type of data context parameter, passed to compiled query.

TResult

Query result type.

Compile<TDc, TArg1, TResult>(IDataContext, Expression<Func<TDc, TArg1, TResult>>)

Compiles the query with parameter.

public static Func<TDc, TArg1, TResult> Compile<TDc, TArg1, TResult>(this IDataContext dataContext, Expression<Func<TDc, TArg1, TResult>> query) where TDc : IDataContext

Parameters

dataContext IDataContext

Data connection context.

query Expression<Func<TDc, TArg1, TResult>>

The query expression to be compiled.

Returns

Func<TDc, TArg1, TResult>

A generic delegate that represents the compiled query.

Type Parameters

TDc

Type of data context parameter, passed to compiled query.

TArg1

Type of parameter for compiled query.

TResult

Query result type.

Compile<TDc, TArg1, TArg2, TResult>(IDataContext, Expression<Func<TDc, TArg1, TArg2, TResult>>)

Compiles the query with two parameters.

public static Func<TDc, TArg1, TArg2, TResult> Compile<TDc, TArg1, TArg2, TResult>(this IDataContext dataContext, Expression<Func<TDc, TArg1, TArg2, TResult>> query) where TDc : IDataContext

Parameters

dataContext IDataContext

Data connection context.

query Expression<Func<TDc, TArg1, TArg2, TResult>>

The query expression to be compiled.

Returns

Func<TDc, TArg1, TArg2, TResult>

A generic delegate that represents the compiled query.

Type Parameters

TDc

Type of data context parameter, passed to compiled query.

TArg1

Type of first parameter for compiled query.

TArg2

Type of second parameter for compiled query.

TResult

Query result type.

Compile<TDc, TArg1, TArg2, TArg3, TResult>(IDataContext, Expression<Func<TDc, TArg1, TArg2, TArg3, TResult>>)

Compiles the query with three parameters.

public static Func<TDc, TArg1, TArg2, TArg3, TResult> Compile<TDc, TArg1, TArg2, TArg3, TResult>(this IDataContext dataContext, Expression<Func<TDc, TArg1, TArg2, TArg3, TResult>> query) where TDc : IDataContext

Parameters

dataContext IDataContext

Data connection context.

query Expression<Func<TDc, TArg1, TArg2, TArg3, TResult>>

The query expression to be compiled.

Returns

Func<TDc, TArg1, TArg2, TArg3, TResult>

A generic delegate that represents the compiled query.

Type Parameters

TDc

Type of data context parameter, passed to compiled query.

TArg1

Type of first parameter for compiled query.

TArg2

Type of second parameter for compiled query.

TArg3

Type of third parameter for compiled query.

TResult

Query result type.

CreateTableAsync<T>(IDataContext, string?, string?, string?, string?, string?, DefaultNullable, string?, TableOptions, CancellationToken)

Asynchronously creates new table in database for mapping class T. Information about table name, columns names and types is taken from mapping class.

public static Task<ITable<T>> CreateTableAsync<T>(this IDataContext dataContext, string? tableName = null, string? databaseName = null, string? schemaName = null, string? statementHeader = null, string? statementFooter = null, DefaultNullable defaultNullable = DefaultNullable.None, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

statementHeader string

Optional replacement for "CREATE TABLE table_name" header. Header is a template with {0} parameter for table name.

statementFooter string

Optional SQL, appended to generated create table statement.

defaultNullable DefaultNullable

Defines how columns nullability flag should be generated:

- Null - generate only NOT NULL for non-nullable fields. Missing nullability information treated as NULL by database.

- NotNull - generate only NULL for nullable fields. Missing nullability information treated as NOT NULL by database.

- None - explicitly generate NULL and NOT NULL for all columns.

Default value: None.
serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<ITable<T>>

Created table as queryable source.

Type Parameters

T

Mapping class.

CreateTable<T>(IDataContext, string?, string?, string?, string?, string?, DefaultNullable, string?, TableOptions)

Creates new table in database for mapping class T. Information about table name, columns names and types is taken from mapping class.

public static ITable<T> CreateTable<T>(this IDataContext dataContext, string? tableName = null, string? databaseName = null, string? schemaName = null, string? statementHeader = null, string? statementFooter = null, DefaultNullable defaultNullable = DefaultNullable.None, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

statementHeader string

Optional replacement for "CREATE TABLE table_name" header. Header is a template with {0} parameter for table name.

statementFooter string

Optional SQL, appended to generated create table statement.

defaultNullable DefaultNullable

Defines how columns nullability flag should be generated:

- Null - generate only NOT NULL for non-nullable fields. Missing nullability information treated as NULL by database.

- NotNull - generate only NULL for nullable fields. Missing nullability information treated as NOT NULL by database.

- None - explicitly generate NULL and NOT NULL for all columns.

Default value: None.
serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

ITable<T>

Created table as queryable source.

Type Parameters

T

Mapping class.

CreateTempTableAsync<T>(IDataContext, IEnumerable<T>, BulkCopyOptions?, string?, string?, string?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using BulkCopy.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, IEnumerable<T> items, BulkCopyOptions? options = null, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

items IEnumerable<T>

Initial records to insert into created table.

options BulkCopyOptions

Optional BulkCopy options.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, IEnumerable<T>, Action<EntityMappingBuilder<T>>, BulkCopyOptions?, string?, string?, string?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using BulkCopy.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, IEnumerable<T> items, Action<EntityMappingBuilder<T>> setTable, BulkCopyOptions? options = null, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

items IEnumerable<T>

Initial records to insert into created table.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

options BulkCopyOptions

Optional BulkCopy options.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, IQueryable<T>, Action<EntityMappingBuilder<T>>, string?, string?, string?, Func<ITable<T>, Task>?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using data from provided query. Table mapping could be changed using fluent mapper.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, IQueryable<T> items, Action<EntityMappingBuilder<T>> setTable, string? tableName = null, string? databaseName = null, string? schemaName = null, Func<ITable<T>, Task>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

items IQueryable<T>

Query to get records to populate created table with initial data.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Func<ITable<T>, Task>

Optional asynchronous action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, IQueryable<T>, string?, string?, string?, Func<ITable<T>, Task>?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using data from provided query.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, IQueryable<T> items, string? tableName = null, string? databaseName = null, string? schemaName = null, Func<ITable<T>, Task>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

items IQueryable<T>

Query to get records to populate created table with initial data.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Func<ITable<T>, Task>

Optional asynchronous action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, string, IEnumerable<T>, BulkCopyOptions?, string?, string?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using BulkCopy.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, string tableName, IEnumerable<T> items, BulkCopyOptions? options = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IEnumerable<T>

Initial records to insert into created table.

options BulkCopyOptions

Optional BulkCopy options.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, string, IEnumerable<T>, Action<EntityMappingBuilder<T>>, BulkCopyOptions?, string?, string?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using BulkCopy.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, string tableName, IEnumerable<T> items, Action<EntityMappingBuilder<T>> setTable, BulkCopyOptions? options = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IEnumerable<T>

Initial records to insert into created table.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

options BulkCopyOptions

Optional BulkCopy options.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, string?, IQueryable<T>, Action<EntityMappingBuilder<T>>, string?, string?, Func<ITable<T>, Task>?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using data from provided query. Table mapping could be changed using fluent mapper.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, string? tableName, IQueryable<T> items, Action<EntityMappingBuilder<T>> setTable, string? databaseName = null, string? schemaName = null, Func<ITable<T>, Task>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IQueryable<T>

Query to get records to populate created table with initial data.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Func<ITable<T>, Task>

Optional asynchronous action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, string?, IQueryable<T>, string?, string?, Func<ITable<T>, Task>?, string?, TableOptions, CancellationToken)

Creates new temporary table and populate it using data from provided query.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, string? tableName, IQueryable<T> items, string? databaseName = null, string? schemaName = null, Func<ITable<T>, Task>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IQueryable<T>

Query to get records to populate created table with initial data.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Func<ITable<T>, Task>

Optional asynchronous action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTableAsync<T>(IDataContext, string?, string?, string?, string?, TableOptions, CancellationToken)

Creates new temporary table.

public static Task<TempTable<T>> CreateTempTableAsync<T>(this IDataContext db, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, CancellationToken cancellationToken = default) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, IEnumerable<T>, BulkCopyOptions?, string?, string?, string?, string?, TableOptions)

Creates new temporary table and populate it using BulkCopy.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, IEnumerable<T> items, BulkCopyOptions? options = null, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

items IEnumerable<T>

Initial records to insert into created table.

options BulkCopyOptions

Optional BulkCopy options.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, IEnumerable<T>, Action<EntityMappingBuilder<T>>, BulkCopyOptions?, string?, string?, string?, string?, TableOptions)

Creates new temporary table and populate it using BulkCopy.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, IEnumerable<T> items, Action<EntityMappingBuilder<T>> setTable, BulkCopyOptions? options = null, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

items IEnumerable<T>

Initial records to insert into created table.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

options BulkCopyOptions

Optional BulkCopy options.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, IQueryable<T>, Action<EntityMappingBuilder<T>>, string?, string?, string?, Action<ITable<T>>?, string?, TableOptions)

Creates new temporary table and populate it using data from provided query. Table mapping could be changed using fluent mapper.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, IQueryable<T> items, Action<EntityMappingBuilder<T>> setTable, string? tableName = null, string? databaseName = null, string? schemaName = null, Action<ITable<T>>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

items IQueryable<T>

Query to get records to populate created table with initial data.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Action<ITable<T>>

Optional action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, IQueryable<T>, string?, string?, string?, Action<ITable<T>>?, string?, TableOptions)

Creates new temporary table and populate it using data from provided query.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, IQueryable<T> items, string? tableName = null, string? databaseName = null, string? schemaName = null, Action<ITable<T>>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

items IQueryable<T>

Query to get records to populate created table with initial data.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Action<ITable<T>>

Optional action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, string, IEnumerable<T>, BulkCopyOptions?, string?, string?, string?, TableOptions)

Creates new temporary table and populate it using BulkCopy.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, string tableName, IEnumerable<T> items, BulkCopyOptions? options = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IEnumerable<T>

Initial records to insert into created table.

options BulkCopyOptions

Optional BulkCopy options.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, string, IEnumerable<T>, Action<EntityMappingBuilder<T>>, BulkCopyOptions?, string?, string?, string?, TableOptions)

Creates new temporary table and populate it using BulkCopy.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, string tableName, IEnumerable<T> items, Action<EntityMappingBuilder<T>> setTable, BulkCopyOptions? options = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IEnumerable<T>

Initial records to insert into created table.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

options BulkCopyOptions

Optional BulkCopy options.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, string?, IQueryable<T>, Action<EntityMappingBuilder<T>>, string?, string?, Action<ITable<T>>?, string?, TableOptions)

Creates new temporary table and populate it using data from provided query. Table mapping could be changed using fluent mapper.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, string? tableName, IQueryable<T> items, Action<EntityMappingBuilder<T>> setTable, string? databaseName = null, string? schemaName = null, Action<ITable<T>>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IQueryable<T>

Query to get records to populate created table with initial data.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Action<ITable<T>>

Optional action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, string?, IQueryable<T>, string?, string?, Action<ITable<T>>?, string?, TableOptions)

Creates new temporary table and populate it using data from provided query.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, string? tableName, IQueryable<T> items, string? databaseName = null, string? schemaName = null, Action<ITable<T>>? action = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

items IQueryable<T>

Query to get records to populate created table with initial data.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

action Action<ITable<T>>

Optional action that will be executed after table creation but before it populated with data from items.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

CreateTempTable<T>(IDataContext, string?, string?, string?, string?, TableOptions)

Creates new temporary table.

public static TempTable<T> CreateTempTable<T>(this IDataContext db, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary) where T : class

Parameters

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

DeleteAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously deletes record in table, identified by T mapping class. Record to delete identified by match on primary key value from obj value.

public static Task<int> DeleteAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data for delete operation.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

Delete<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Deletes record in table, identified by T mapping class. Record to delete identified by match on primary key value from obj value.

public static int Delete<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data for delete operation.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.

DropTableAsync<T>(IDataContext, string?, string?, string?, bool?, string?, TableOptions, CancellationToken)

Asynchronously drops table identified by mapping class T.

public static Task DropTableAsync<T>(this IDataContext dataContext, string? tableName = null, string? databaseName = null, string? schemaName = null, bool? throwExceptionIfNotExists = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default)

Parameters

dataContext IDataContext

Database connection context.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

throwExceptionIfNotExists bool?

If false, any exception during drop operation will be silently caught and 0 returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value: true.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task

Asynchronous operation completion task.

Type Parameters

T

Mapping class.

DropTableAsync<T>(ITable<T>, string?, string?, string?, bool?, string?, TableOptions, CancellationToken)

Asynchronously drops table identified by table parameter.

public static Task DropTableAsync<T>(this ITable<T> table, string? tableName = null, string? databaseName = null, string? schemaName = null, bool? throwExceptionIfNotExists = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

table ITable<T>

Dropped table.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

throwExceptionIfNotExists bool?

If false, any exception during drop operation will be silently caught and 0 returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value: true.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task

Asynchronous operation completion task.

Type Parameters

T

Mapping class.

DropTable<T>(IDataContext, string?, string?, string?, bool?, string?, TableOptions)

Drops table identified by mapping class T.

public static void DropTable<T>(this IDataContext dataContext, string? tableName = null, string? databaseName = null, string? schemaName = null, bool? throwExceptionIfNotExists = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet)

Parameters

dataContext IDataContext

Database connection context.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

throwExceptionIfNotExists bool?

If false, any exception during drop operation will be silently caught and 0 returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value: true.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Type Parameters

T

Mapping class.

DropTable<T>(ITable<T>, string?, string?, string?, bool?, string?, TableOptions)

Drops table identified by table parameter.

public static void DropTable<T>(this ITable<T> table, string? tableName = null, string? databaseName = null, string? schemaName = null, bool? throwExceptionIfNotExists = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

table ITable<T>

Dropped table.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

throwExceptionIfNotExists bool?

If false, any exception during drop operation will be silently caught and 0 returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value: true.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Type Parameters

T

Mapping class.

FromSql<TEntity>(IDataContext, RawSqlString, params object?[])

Creates a LINQ query based on a raw SQL query.

If the database provider supports composing on the supplied SQL, you can compose on top of the raw SQL query using LINQ operators -

context.FromSql<Blogs>("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name);

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter -

context.FromSql<Blogs>("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm);

This overload also accepts DbParameter instances as parameter values.

context.FromSql<Blogs>("SELECT * FROM [dbo].[SearchBlogs]({0})", new DataParameter("@searchTerm", userSuppliedSearchTerm, DataType.Int64));
public static IQueryable<TEntity> FromSql<TEntity>(this IDataContext dataContext, RawSqlString sql, params object?[] parameters)

Parameters

dataContext IDataContext

Database connection context.

sql RawSqlString

The raw SQL query

parameters object[]

The values to be assigned to parameters.

Returns

IQueryable<TEntity>

An IQueryable<T> representing the raw SQL query.

Type Parameters

TEntity

Source query record type.

Remarks

Additional parentheses will be added to the query if first word in raw query is 'SELECT', otherwise users are responsible to add them themselves.

GetCte<T>(IDataContext, Func<IQueryable<T>, IQueryable<T>>, string?)

Helps to define a recursive CTE.

public static IQueryable<T> GetCte<T>(this IDataContext dataContext, Func<IQueryable<T>, IQueryable<T>> cteBody, string? cteTableName = null) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

cteBody Func<IQueryable<T>, IQueryable<T>>

Recursive query body.

cteTableName string

Common table expression name.

Returns

IQueryable<T>

Common table expression.

Type Parameters

T

Source query record type.

GetCte<T>(IDataContext, string?, Func<IQueryable<T>, IQueryable<T>>)

Helps to define a recursive CTE.

public static IQueryable<T> GetCte<T>(this IDataContext dataContext, string? cteTableName, Func<IQueryable<T>, IQueryable<T>> cteBody) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

cteTableName string

Common table expression name.

cteBody Func<IQueryable<T>, IQueryable<T>>

Recursive query body.

Returns

IQueryable<T>

Common table expression.

Type Parameters

T

Source query record type.

GetTable<T>(IDataContext)

Returns queryable source for specified mapping class for current connection, mapped to database table or view.

public static ITable<T> GetTable<T>(this IDataContext dataContext) where T : class

Parameters

dataContext IDataContext

Data connection context.

Returns

ITable<T>

Queryable source.

Type Parameters

T

Mapping class type.

GetTable<T>(IDataContext, object?, MethodInfo, params object?[])

Returns queryable source for specified mapping class for current connection, mapped to table expression or function. It could be used e.g. for queries to table-valued functions or to decorate queried table with hints.

public static ITable<T> GetTable<T>(this IDataContext dataContext, object? instance, MethodInfo methodInfo, params object?[] parameters) where T : class

Parameters

dataContext IDataContext

Data connection context.

instance object

Instance object for methodInfo method or null for static method.

methodInfo MethodInfo

Method, decorated with expression attribute, based on Sql.TableFunctionAttribute.

parameters object[]

Parameters for methodInfo method.

Returns

ITable<T>

Queryable source.

Type Parameters

T

Mapping class type.

InsertAsync<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Inserts record asynchronously into table, identified by T mapping class, using values from obj parameter.

public static Task<int> InsertAsync<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

InsertAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Inserts record asynchronously into table, identified by T mapping class, using values from obj parameter.

public static Task<int> InsertAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

InsertOrReplaceAsync<T>(IDataContext, T, InsertOrUpdateColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts new record into table, identified by T mapping class, using values from obj parameter or update existing record, identified by match on primary key value.

public static Task<int> InsertOrReplaceAsync<T>(this IDataContext dataContext, T obj, InsertOrUpdateColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert or update.

columnFilter InsertOrUpdateColumnFilter<T>

Filter columns to insert and update.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

InsertOrReplaceAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts new record into table, identified by T mapping class, using values from obj parameter or update existing record, identified by match on primary key value.

public static Task<int> InsertOrReplaceAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert or update.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

InsertOrReplace<T>(IDataContext, T, InsertOrUpdateColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Inserts new record into table, identified by T mapping class, using values from obj parameter or update existing record, identified by match on primary key value.

public static int InsertOrReplace<T>(this IDataContext dataContext, T obj, InsertOrUpdateColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert or update.

columnFilter InsertOrUpdateColumnFilter<T>

Filter columns to insert and update. Parameters: entity, column descriptor and operation (true for insert )

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.

InsertOrReplace<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Inserts new record into table, identified by T mapping class, using values from obj parameter or update existing record, identified by match on primary key value.

public static int InsertOrReplace<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert or update.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.

InsertWithDecimalIdentityAsync<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as decimal value.

public static Task<decimal> InsertWithDecimalIdentityAsync<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<decimal>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithDecimalIdentityAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as decimal value.

public static Task<decimal> InsertWithDecimalIdentityAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<decimal>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithDecimalIdentity<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as decimal value.

public static decimal InsertWithDecimalIdentity<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

decimal

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithDecimalIdentity<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as decimal value.

public static decimal InsertWithDecimalIdentity<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

decimal

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithIdentityAsync<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record.

public static Task<object> InsertWithIdentityAsync<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<object>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithIdentityAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record.

public static Task<object> InsertWithIdentityAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<object>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithIdentity<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record.

public static object InsertWithIdentity<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

object

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithIdentity<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record.

public static object InsertWithIdentity<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

object

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt32IdentityAsync<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as int value.

public static Task<int> InsertWithInt32IdentityAsync<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt32IdentityAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as int value.

public static Task<int> InsertWithInt32IdentityAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt32Identity<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as int value.

public static int InsertWithInt32Identity<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt32Identity<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as int value.

public static int InsertWithInt32Identity<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt64IdentityAsync<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as long value.

public static Task<long> InsertWithInt64IdentityAsync<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<long>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt64IdentityAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as long value.

public static Task<long> InsertWithInt64IdentityAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<long>

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt64Identity<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as long value.

public static long InsertWithInt64Identity<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

long

Inserted record's identity value.

Type Parameters

T

Mapping class.

InsertWithInt64Identity<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter. Returns identity value for inserted record as long value.

public static long InsertWithInt64Identity<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

long

Inserted record's identity value.

Type Parameters

T

Mapping class.

Insert<T>(IDataContext, T, InsertColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter.

public static int Insert<T>(this IDataContext dataContext, T obj, InsertColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

columnFilter InsertColumnFilter<T>

Filter columns to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.

Insert<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Inserts record into table, identified by T mapping class, using values from obj parameter.

public static int Insert<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to insert.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.

IntoTempTableAsync<T>(IEnumerable<T>, IDataContext, string?, string?, string?, string?, TableOptions, BulkCopyOptions?, CancellationToken)

Creates new temporary table and populate it using BulkCopy.

public static Task<TempTable<T>> IntoTempTableAsync<T>(this IEnumerable<T> items, IDataContext db, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, BulkCopyOptions? options = null, CancellationToken cancellationToken = default) where T : class

Parameters

items IEnumerable<T>

Initial records to insert into created table.

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

options BulkCopyOptions

Optional BulkCopy options.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

IntoTempTableAsync<T>(IQueryable<T>, string?, string?, string?, string?, TableOptions, Func<ITable<T>, Task>?, Action<EntityMappingBuilder<T>>?, CancellationToken)

Creates new temporary table and populate it using data from provided query. Table mapping could be changed using fluent mapper.

public static Task<TempTable<T>> IntoTempTableAsync<T>(this IQueryable<T> items, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, Func<ITable<T>, Task>? action = null, Action<EntityMappingBuilder<T>>? setTable = null, CancellationToken cancellationToken = default) where T : class

Parameters

items IQueryable<T>

Query to get records to populate created table with initial data.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

action Func<ITable<T>, Task>

Optional asynchronous action that will be executed after table creation but before it populated with data from items.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<TempTable<T>>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

IntoTempTable<T>(IEnumerable<T>, IDataContext, string?, string?, string?, string?, TableOptions, BulkCopyOptions?)

Creates new temporary table and populate it using BulkCopy.

public static TempTable<T> IntoTempTable<T>(this IEnumerable<T> items, IDataContext db, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, BulkCopyOptions? options = null) where T : class

Parameters

items IEnumerable<T>

Initial records to insert into created table.

db IDataContext

Database connection instance.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

options BulkCopyOptions

Optional BulkCopy options.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

IntoTempTable<T>(IQueryable<T>, string?, string?, string?, string?, TableOptions, Action<ITable<T>>?, Action<EntityMappingBuilder<T>>?)

Creates new temporary table and populate it using data from provided query.

public static TempTable<T> IntoTempTable<T>(this IQueryable<T> items, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.IsTemporary, Action<ITable<T>>? action = null, Action<EntityMappingBuilder<T>>? setTable = null) where T : class

Parameters

items IQueryable<T>

Query to get records to populate created table with initial data.

tableName string

Optional name of temporary table. If not specified, value from mapping will be used.

databaseName string

Optional name of table's database. If not specified, value from mapping will be used.

schemaName string

Optional name of table schema/owner. If not specified, value from mapping will be used.

serverName string

Optional name of linked server. If not specified, value from mapping will be used.

tableOptions TableOptions

Optional Table options. Default is IsTemporary.

action Action<ITable<T>>

Optional action that will be executed after table creation, but before it populated with data from items.

setTable Action<EntityMappingBuilder<T>>

Action to modify T entity's mapping using fluent mapping. Note that context mapping schema must be writable to allow it. You can enable writable MappingSchema using UseEnableContextSchemaEdit(DataOptions, bool) configuration helper or enable writeable schemata globally using EnableContextSchemaEdit option. Latter option is not recommended as it will affect performance significantly.

Returns

TempTable<T>

Returns temporary table instance.

Type Parameters

T

Table record mapping class.

SelectQuery<TEntity>(IDataContext, Expression<Func<TEntity>>)

Creates a LINQ query based on expression. Returned IQueryable<T> represents single record.

Could be useful for function calls, querying of database variables, properties or sub-queries.
public static IQueryable<TEntity> SelectQuery<TEntity>(this IDataContext dataContext, Expression<Func<TEntity>> selector)

Parameters

dataContext IDataContext

Database connection context.

selector Expression<Func<TEntity>>

Value selection expression.

Returns

IQueryable<TEntity>

An IQueryable<T> representing single record.

Type Parameters

TEntity

Type of result.

Examples

Complex record:

db.SelectQuery(() => new { Version = 1, CurrentTimeStamp = Sql.CurrentTimeStamp });

Scalar value:

db.SelectQuery(() => Sql.CurrentTimeStamp);

Remarks

Method works for most supported database engines, except databases which do not support

SELECT Value
without FROM statement.

For Oracle it will be translated to
SELECT Value FROM SYS.DUAL

UpdateAsync<T>(IDataContext, T, UpdateColumnFilter<T>?, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously updates record in table, identified by T mapping class, using values from obj parameter. Record to update identified by match on primary key value from obj value.

public static Task<int> UpdateAsync<T>(this IDataContext dataContext, T obj, UpdateColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to update.

columnFilter UpdateColumnFilter<T>

Filter columns to update.

tableName string

Name of the table

databaseName string

Name of the database

schemaName string

Name of the schema

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

UpdateAsync<T>(IDataContext, T, string?, string?, string?, string?, TableOptions, CancellationToken)

Asynchronously updates record in table, identified by T mapping class, using values from obj parameter. Record to update identified by match on primary key value from obj value.

public static Task<int> UpdateAsync<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken token = default) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to update.

tableName string

Name of the table

databaseName string

Name of the database

schemaName string

Name of the schema

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

token CancellationToken

Optional asynchronous operation cancellation token.

Returns

Task<int>

Number of affected records.

Type Parameters

T

Mapping class.

Update<T>(IDataContext, T, UpdateColumnFilter<T>?, string?, string?, string?, string?, TableOptions)

Updates record in table, identified by T mapping class, using values from obj parameter. Record to update identified by match on primary key value from obj value.

public static int Update<T>(this IDataContext dataContext, T obj, UpdateColumnFilter<T>? columnFilter, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to update.

columnFilter UpdateColumnFilter<T>

Filter columns to update.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.

Update<T>(IDataContext, T, string?, string?, string?, string?, TableOptions)

Updates record in table, identified by T mapping class, using values from obj parameter. Record to update identified by match on primary key value from obj value.

public static int Update<T>(this IDataContext dataContext, T obj, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : notnull

Parameters

dataContext IDataContext

Database connection context.

obj T

Object with data to update.

tableName string

Optional table name to override default table name, extracted from T mapping.

databaseName string

Optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.

schemaName string

Optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.

serverName string

Optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.

tableOptions TableOptions

Table options. See TableOptions enum for support information per provider.

Returns

int

Number of affected records.

Type Parameters

T

Mapping class.