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
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
dataContextIDataContextData connection context.
queryExpression<Func<TDc, TResult>>The query expression to be compiled.
Returns
- Func<TDc, TResult>
A generic delegate that represents the compiled query.
Type Parameters
TDcType of data context parameter, passed to compiled query.
TResultQuery 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
dataContextIDataContextData connection context.
queryExpression<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
TDcType of data context parameter, passed to compiled query.
TArg1Type of parameter for compiled query.
TResultQuery 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
dataContextIDataContextData connection context.
queryExpression<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
TDcType of data context parameter, passed to compiled query.
TArg1Type of first parameter for compiled query.
TArg2Type of second parameter for compiled query.
TResultQuery 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
dataContextIDataContextData connection context.
queryExpression<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
TDcType of data context parameter, passed to compiled query.
TArg1Type of first parameter for compiled query.
TArg2Type of second parameter for compiled query.
TArg3Type of third parameter for compiled query.
TResultQuery 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
dataContextIDataContextDatabase connection context.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
statementHeaderstringOptional replacement for
"CREATE TABLE table_name"header. Header is a template with{0}parameter for table name.statementFooterstringOptional SQL, appended to generated create table statement.
defaultNullableDefaultNullableDefines how columns nullability flag should be generated:
- Null - generate only
NOT NULLfor non-nullable fields. Missing nullability information treated asNULLby database.- NotNull - generate only
NULLfor nullable fields. Missing nullability information treated asNOT NULLby database.- None - explicitly generate
Default value: None.NULLandNOT NULLfor all columns.serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
statementHeaderstringOptional replacement for
"CREATE TABLE table_name"header. Header is a template with{0}parameter for table name.statementFooterstringOptional SQL, appended to generated create table statement.
defaultNullableDefaultNullableDefines how columns nullability flag should be generated:
- Null - generate only
NOT NULLfor non-nullable fields. Missing nullability information treated asNULLby database.- NotNull - generate only
NULLfor nullable fields. Missing nullability information treated asNOT NULLby database.- None - explicitly generate
Default value: None.NULLandNOT NULLfor all columns.serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- ITable<T>
Created table as queryable source.
Type Parameters
TMapping 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
dbIDataContextDatabase connection instance.
itemsIEnumerable<T>Initial records to insert into created table.
optionsBulkCopyOptionsOptional BulkCopy options.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIEnumerable<T>Initial records to insert into created table.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.optionsBulkCopyOptionsOptional BulkCopy options.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIQueryable<T>Query to get records to populate created table with initial data.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionFunc<ITable<T>, Task>Optional asynchronous action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIQueryable<T>Query to get records to populate created table with initial data.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionFunc<ITable<T>, Task>Optional asynchronous action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIEnumerable<T>Initial records to insert into created table.
optionsBulkCopyOptionsOptional BulkCopy options.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIEnumerable<T>Initial records to insert into created table.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.optionsBulkCopyOptionsOptional BulkCopy options.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIQueryable<T>Query to get records to populate created table with initial data.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionFunc<ITable<T>, Task>Optional asynchronous action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIQueryable<T>Query to get records to populate created table with initial data.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionFunc<ITable<T>, Task>Optional asynchronous action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIEnumerable<T>Initial records to insert into created table.
optionsBulkCopyOptionsOptional BulkCopy options.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIEnumerable<T>Initial records to insert into created table.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.optionsBulkCopyOptionsOptional BulkCopy options.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIQueryable<T>Query to get records to populate created table with initial data.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionAction<ITable<T>>Optional action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
itemsIQueryable<T>Query to get records to populate created table with initial data.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionAction<ITable<T>>Optional action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIEnumerable<T>Initial records to insert into created table.
optionsBulkCopyOptionsOptional BulkCopy options.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIEnumerable<T>Initial records to insert into created table.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.optionsBulkCopyOptionsOptional BulkCopy options.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIQueryable<T>Query to get records to populate created table with initial data.
setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionAction<ITable<T>>Optional action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
itemsIQueryable<T>Query to get records to populate created table with initial data.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
actionAction<ITable<T>>Optional action that will be executed after table creation but before it populated with data from
items.serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
dataContextIDataContextDatabase connection context.
objTObject with data for delete operation.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data for delete operation.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
throwExceptionIfNotExistsbool?If
false, any exception during drop operation will be silently caught and0returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true.serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task
Asynchronous operation completion task.
Type Parameters
TMapping 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
tableITable<T>Dropped table.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
throwExceptionIfNotExistsbool?If
false, any exception during drop operation will be silently caught and0returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true.serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task
Asynchronous operation completion task.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
throwExceptionIfNotExistsbool?If
false, any exception during drop operation will be silently caught and0returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true.serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Type Parameters
TMapping 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
tableITable<T>Dropped table.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
throwExceptionIfNotExistsbool?If
false, any exception during drop operation will be silently caught and0returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true.serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
sqlRawSqlStringThe raw SQL query
parametersobject[]The values to be assigned to parameters.
Returns
- IQueryable<TEntity>
An IQueryable<T> representing the raw SQL query.
Type Parameters
TEntitySource 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
dataContextIDataContextDatabase connection context.
cteBodyFunc<IQueryable<T>, IQueryable<T>>Recursive query body.
cteTableNamestringCommon table expression name.
Returns
- IQueryable<T>
Common table expression.
Type Parameters
TSource 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
dataContextIDataContextDatabase connection context.
cteTableNamestringCommon table expression name.
cteBodyFunc<IQueryable<T>, IQueryable<T>>Recursive query body.
Returns
- IQueryable<T>
Common table expression.
Type Parameters
TSource 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
dataContextIDataContextData connection context.
Returns
- ITable<T>
Queryable source.
Type Parameters
TMapping 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
dataContextIDataContextData connection context.
instanceobjectInstance object for
methodInfomethod or null for static method.methodInfoMethodInfoMethod, decorated with expression attribute, based on Sql.TableFunctionAttribute.
parametersobject[]Parameters for
methodInfomethod.
Returns
- ITable<T>
Queryable source.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert or update.
columnFilterInsertOrUpdateColumnFilter<T>Filter columns to insert and update.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert or update.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert or update.
columnFilterInsertOrUpdateColumnFilter<T>Filter columns to insert and update. Parameters: entity, column descriptor and operation (
truefor insert )tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert or update.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- decimal
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- decimal
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- object
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- object
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- long
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- long
Inserted record's identity value.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
columnFilterInsertColumnFilter<T>Filter columns to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to insert.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping 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
itemsIEnumerable<T>Initial records to insert into created table.
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
optionsBulkCopyOptionsOptional BulkCopy options.
cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
itemsIQueryable<T>Query to get records to populate created table with initial data.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
actionFunc<ITable<T>, Task>Optional asynchronous action that will be executed after table creation but before it populated with data from
items.setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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.cancellationTokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
itemsIEnumerable<T>Initial records to insert into created table.
dbIDataContextDatabase connection instance.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
optionsBulkCopyOptionsOptional BulkCopy options.
Returns
- TempTable<T>
Returns temporary table instance.
Type Parameters
TTable 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
itemsIQueryable<T>Query to get records to populate created table with initial data.
tableNamestringOptional name of temporary table. If not specified, value from mapping will be used.
databaseNamestringOptional name of table's database. If not specified, value from mapping will be used.
schemaNamestringOptional name of table schema/owner. If not specified, value from mapping will be used.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsOptional Table options. Default is IsTemporary.
actionAction<ITable<T>>Optional action that will be executed after table creation, but before it populated with data from
items.setTableAction<EntityMappingBuilder<T>>Action to modify
Tentity'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
TTable 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
dataContextIDataContextDatabase connection context.
selectorExpression<Func<TEntity>>Value selection expression.
Returns
- IQueryable<TEntity>
An IQueryable<T> representing single record.
Type Parameters
TEntityType 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
dataContextIDataContextDatabase connection context.
objTObject with data to update.
columnFilterUpdateColumnFilter<T>Filter columns to update.
tableNamestringName of the table
databaseNamestringName of the database
schemaNamestringName of the schema
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to update.
tableNamestringName of the table
databaseNamestringName of the database
schemaNamestringName of the schema
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to update.
columnFilterUpdateColumnFilter<T>Filter columns to update.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping 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
dataContextIDataContextDatabase connection context.
objTObject with data to update.
tableNamestringOptional table name to override default table name, extracted from
Tmapping.databaseNamestringOptional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
schemaNamestringOptional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
serverNamestringOptional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Number of affected records.
Type Parameters
TMapping class.