Class TempTable<T>
Temporary table. Temporary table is a table, created when you create instance of this class and deleted when you dispose it. It uses regular tables even if underlying database supports temporary tables concept.
Inheritance
Namespace: LinqToDB
Assembly: linq2db.dll
Syntax
public class TempTable<T> : object, ITable<T>, IExpressionQuery<T>, IQueryProviderAsync, IExpressionQuery, ITableMutable<T>, IAsyncDisposable
Type Parameters
Name | Description |
---|---|
T | Table record mapping class. |
Constructors
| Improve this Doc View SourceTempTable(IDataContext, IEnumerable<T>, BulkCopyOptions, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions)
Creates new temporary table and populate it using BulkCopy.
Declaration
public TempTable(IDataContext db, IEnumerable<T> items, BulkCopyOptions options = null, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
IEnumerable<T> | items | Initial records to insert into created table. |
BulkCopyOptions | options | Optional BulkCopy options. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
TempTable(IDataContext, IQueryable<T>, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<Action<ITable<T>>>, Nullable<String>, TableOptions)
Creates new temporary table and populate it using data from provided query.
Declaration
public TempTable(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)0)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
IQueryable<T> | items | Query to get records to populate created table with initial data. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<Action<ITable<T>>> | action | Optional action that will be executed after table creation but before it populated with data from |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
TempTable(IDataContext, Nullable<String>, IEnumerable<T>, BulkCopyOptions, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions)
Creates new temporary table and populate it using BulkCopy.
Declaration
public TempTable(IDataContext db, string? tableName, IEnumerable<T> items, BulkCopyOptions options = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
IEnumerable<T> | items | Initial records to insert into created table. |
BulkCopyOptions | options | Optional BulkCopy options. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
TempTable(IDataContext, Nullable<String>, IQueryable<T>, Nullable<String>, Nullable<String>, Nullable<Action<ITable<T>>>, Nullable<String>, TableOptions)
Creates new temporary table and populate it using data from provided query.
Declaration
public TempTable(IDataContext db, string? tableName, IQueryable<T> items, string? databaseName = null, string? schemaName = null, Action<ITable<T>>? action = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
IQueryable<T> | items | Query to get records to populate created table with initial data. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<Action<ITable<T>>> | action | Optional action that will be executed after table creation but before it populated with data from |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
TempTable(IDataContext, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions)
Creates new temporary table.
Declaration
public TempTable(IDataContext db, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
TempTable(ITable<T>)
Configures a temporary table that will be dropped when this instance is disposed
Declaration
protected TempTable(ITable<T> table)
Parameters
Type | Name | Description |
---|---|---|
ITable<T> | table | Table instance. |
Fields
| Improve this Doc View SourceTotalCopied
Gets total number of records, inserted into table using BulkCopy.
Declaration
public long TotalCopied
Field Value
Type | Description |
---|---|
System.Int64 |
Properties
| Improve this Doc View SourceDatabaseName
Declaration
public string? DatabaseName { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
DataContext
Gets data connection, associated with current table.
Declaration
public IDataContext DataContext { get; }
Property Value
Type | Description |
---|---|
IDataContext |
SchemaName
Declaration
public string? SchemaName { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
ServerName
Declaration
public string? ServerName { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
TableID
Declaration
public string? TableID { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
TableName
Declaration
public string TableName { get; }
Property Value
Type | Description |
---|---|
System.String |
TableOptions
Declaration
public TableOptions TableOptions { get; }
Property Value
Type | Description |
---|---|
TableOptions |
Methods
| Improve this Doc View SourceCopy(IEnumerable<T>, BulkCopyOptions)
Insert new records into table using BulkCopy.
Declaration
public long Copy(IEnumerable<T> items, BulkCopyOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | Records to insert into table. |
BulkCopyOptions | options | Optional BulkCopy options. |
Returns
Type | Description |
---|---|
System.Int64 | Number of records, inserted into table. |
CopyAsync(IEnumerable<T>, BulkCopyOptions, CancellationToken)
Insert new records into table using BulkCopy.
Declaration
public async Task<long> CopyAsync(IEnumerable<T> items, BulkCopyOptions options = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | Records to insert into table. |
BulkCopyOptions | options | Optional BulkCopy options. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<System.Int64> | Number of records, inserted into table. |
CreateAsync(IDataContext, IEnumerable<T>, BulkCopyOptions, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions, CancellationToken)
Creates new temporary table and populate it using BulkCopy.
Declaration
public static Task<TempTable<T>> CreateAsync(IDataContext db, IEnumerable<T> items, BulkCopyOptions options = null, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
IEnumerable<T> | items | Initial records to insert into created table. |
BulkCopyOptions | options | Optional BulkCopy options. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<TempTable<T>> |
CreateAsync(IDataContext, IQueryable<T>, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<Func<ITable<T>, Task>>, Nullable<String>, TableOptions, CancellationToken)
Creates new temporary table and populate it using data from provided query.
Declaration
public static async Task<TempTable<T>> CreateAsync(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)0, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
IQueryable<T> | items | Query to get records to populate created table with initial data. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<Func<ITable<T>, Task>> | action | Optional asynchronous action that will be executed after table creation but before it populated with data from |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<TempTable<T>> |
CreateAsync(IDataContext, Nullable<String>, IEnumerable<T>, BulkCopyOptions, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions, CancellationToken)
Creates new temporary table and populate it using BulkCopy.
Declaration
public static async Task<TempTable<T>> CreateAsync(IDataContext db, string? tableName, IEnumerable<T> items, BulkCopyOptions options = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
IEnumerable<T> | items | Initial records to insert into created table. |
BulkCopyOptions | options | Optional BulkCopy options. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<TempTable<T>> |
CreateAsync(IDataContext, Nullable<String>, IQueryable<T>, Nullable<String>, Nullable<String>, Nullable<Func<ITable<T>, Task>>, Nullable<String>, TableOptions, CancellationToken)
Creates new temporary table and populate it using data from provided query.
Declaration
public static Task<TempTable<T>> CreateAsync(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)0, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
IQueryable<T> | items | Query to get records to populate created table with initial data. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<Func<ITable<T>, Task>> | action | Optional asynchronous action that will be executed after table creation but before it populated with data from |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<TempTable<T>> |
CreateAsync(IDataContext, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions, CancellationToken)
Creates new temporary table.
Declaration
public static async Task<TempTable<T>> CreateAsync(IDataContext db, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = (TableOptions)0, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | db | Database connection instance. |
System.Nullable<System.String> | tableName | Optional name of temporary table. If not specified, value from mapping will be used. |
System.Nullable<System.String> | databaseName | Optional name of table's database. If not specified, value from mapping will be used. |
System.Nullable<System.String> | schemaName | Optional name of table schema/owner. If not specified, value from mapping will be used. |
System.Nullable<System.String> | serverName | Optional name of linked server. If not specified, value from mapping will be used. |
TableOptions | tableOptions | Optional Table options. If not specified, value from mapping will be used. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<TempTable<T>> |
Dispose()
Declaration
public virtual void Dispose()
DisposeAsync()
Declaration
public virtual Task DisposeAsync()
Returns
Type | Description |
---|---|
Task |
Insert(IQueryable<T>)
Insert data into table using records, returned by provided query.
Declaration
public long Insert(IQueryable<T> items)
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | items | Query with records to insert into temporary table. |
Returns
Type | Description |
---|---|
System.Int64 | Number of records, inserted into table. |
InsertAsync(IQueryable<T>, CancellationToken)
Insert data into table using records, returned by provided query.
Declaration
public async Task<long> InsertAsync(IQueryable<T> items, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | items | Query with records to insert into temporary table. |
CancellationToken | cancellationToken | Asynchronous operation cancellation token. |
Returns
Type | Description |
---|---|
Task<System.Int64> | Number of records, inserted into table. |
Explicit Interface Implementations
| Improve this Doc View SourceIQueryProviderAsync.ExecuteAsync<TResult>(Expression, CancellationToken)
Declaration
Task<TResult> IQueryProviderAsync.ExecuteAsync<TResult>(Expression expression, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<TResult> |
Type Parameters
Name | Description |
---|---|
TResult |
IQueryProviderAsync.ExecuteAsyncEnumerable<TResult>(Expression, CancellationToken)
Declaration
Task<IAsyncEnumerable<TResult>> IQueryProviderAsync.ExecuteAsyncEnumerable<TResult>(Expression expression, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IAsyncEnumerable<TResult>> |
Type Parameters
Name | Description |
---|---|
TResult |
ITableMutable<T>.ChangeDatabaseName(Nullable<String>)
Declaration
ITable<T> ITableMutable<T>.ChangeDatabaseName(string? databaseName)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.String> | databaseName |
Returns
Type | Description |
---|---|
ITable<T> |
ITableMutable<T>.ChangeSchemaName(Nullable<String>)
Declaration
ITable<T> ITableMutable<T>.ChangeSchemaName(string? schemaName)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.String> | schemaName |
Returns
Type | Description |
---|---|
ITable<T> |
ITableMutable<T>.ChangeServerName(Nullable<String>)
Declaration
ITable<T> ITableMutable<T>.ChangeServerName(string? serverName)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.String> | serverName |
Returns
Type | Description |
---|---|
ITable<T> |
ITableMutable<T>.ChangeTableID(Nullable<String>)
Declaration
ITable<T> ITableMutable<T>.ChangeTableID(string? tableID)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.String> | tableID |
Returns
Type | Description |
---|---|
ITable<T> |
ITableMutable<T>.ChangeTableName(String)
Declaration
ITable<T> ITableMutable<T>.ChangeTableName(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName |
Returns
Type | Description |
---|---|
ITable<T> |
ITableMutable<T>.ChangeTableOptions(TableOptions)
Declaration
ITable<T> ITableMutable<T>.ChangeTableOptions(TableOptions options)
Parameters
Type | Name | Description |
---|---|---|
TableOptions | options |
Returns
Type | Description |
---|---|
ITable<T> |
IExpressionQuery.Expression
Declaration
Expression IExpressionQuery.Expression { get; }
Returns
Type | Description |
---|---|
Expression |
IExpressionQuery.SqlText
Declaration
string IExpressionQuery.SqlText { get; }
Returns
Type | Description |
---|---|
System.String |
IExpressionQuery<T>.Expression
Declaration
Expression IExpressionQuery<T>.Expression { get; set; }
Returns
Type | Description |
---|---|
Expression |