Class LinqExtensions
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
Contains extension methods for LINQ queries.
public static class LinqExtensions
- Inheritance
-
LinqExtensions
Properties
ExtensionsAdapter
public static IExtensionsAdapter? ExtensionsAdapter { get; set; }
Property Value
ProcessSourceQueryable
Gets or sets callback for preprocessing query before execution. Useful for intercepting queries.
public static Func<IQueryable, IQueryable>? ProcessSourceQueryable { get; set; }
Property Value
Methods
AsCte<TSource>(IQueryable<TSource>)
Specifies a temporary named result set, known as a common table expression (CTE).
public static IQueryable<TSource> AsCte<TSource>(this IQueryable<TSource> source)
Parameters
source
IQueryable<TSource>Source query.
Returns
- IQueryable<TSource>
Common table expression.
Type Parameters
TSource
Source query record type.
AsCte<TSource>(IQueryable<TSource>, string?)
Specifies a temporary named result set, known as a common table expression (CTE).
public static IQueryable<TSource> AsCte<TSource>(this IQueryable<TSource> source, string? name)
Parameters
source
IQueryable<TSource>Source query.
name
stringCommon table expression name.
Returns
- IQueryable<TSource>
Common table expression.
Type Parameters
TSource
Source query record type.
AsQueryable<TElement>(IEnumerable<TElement>, IDataContext)
Converts a generic IEnumerable<T> to Linq To DB query.
public static IQueryable<TElement> AsQueryable<TElement>(this IEnumerable<TElement> source, IDataContext dataContext)
Parameters
source
IEnumerable<TElement>A sequence to convert.
dataContext
IDataContextDatabase connection context.
Returns
- IQueryable<TElement>
An IQueryable<T> that represents the input sequence.
Type Parameters
TElement
The type of the elements of
source
.
Exceptions
- ArgumentNullException
source
is null.
AsSubQuery<TSource>(IQueryable<TSource>)
Defines that sub-query is mandatory for source
query and cannot be removed during the query optimization.
public static IQueryable<TSource> AsSubQuery<TSource>(this IQueryable<TSource> source)
Parameters
source
IQueryable<TSource>Source data query.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSource
Source query record type.
AsSubQuery<TSource>(IQueryable<TSource>, string)
Defines that sub-query is mandatory for source
query and cannot be removed during the query optimization.
public static IQueryable<TSource> AsSubQuery<TSource>(this IQueryable<TSource> source, string queryName)
Parameters
source
IQueryable<TSource>Source data query.
queryName
stringQuery name.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSource
Source query record type.
AsSubQuery<TKey, TElement>(IQueryable<IGrouping<TKey, TElement>>)
Defines that sub-query is mandatory for grouping
query and cannot be removed during the query optimization.
public static IQueryable<TKey> AsSubQuery<TKey, TElement>(this IQueryable<IGrouping<TKey, TElement>> grouping)
Parameters
grouping
IQueryable<IGrouping<TKey, TElement>>Source data query.
Returns
- IQueryable<TKey>
Query converted into sub-query.
Type Parameters
TKey
The type of the key of the IGrouping<TKey, TElement>.
TElement
The type of the values in the IGrouping<TKey, TElement>.
AsSubQuery<TKey, TElement>(IQueryable<IGrouping<TKey, TElement>>, string)
Defines that sub-query is mandatory for grouping
query and cannot be removed during the query optimization.
public static IQueryable<TKey> AsSubQuery<TKey, TElement>(this IQueryable<IGrouping<TKey, TElement>> grouping, string queryName)
Parameters
grouping
IQueryable<IGrouping<TKey, TElement>>Source data query.
queryName
stringQuery name.
Returns
- IQueryable<TKey>
Query converted into sub-query.
Type Parameters
TKey
The type of the key of the IGrouping<TKey, TElement>.
TElement
The type of the values in the IGrouping<TKey, TElement>.
AsUpdatable<T>(IQueryable<T>)
Casts IQueryable<T> query to IUpdatable<T> query.
public static IUpdatable<T> AsUpdatable<T>(this IQueryable<T> source)
Parameters
source
IQueryable<T>Source IQueryable<T> query.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Query record type.
AsValueInsertable<T>(ITable<T>)
Starts insert operation LINQ query definition.
public static IValueInsertable<T> AsValueInsertable<T>(this ITable<T> source) where T : notnull
Parameters
source
ITable<T>Target table.
Returns
- IValueInsertable<T>
Insertable source query.
Type Parameters
T
Target table mapping class.
CrossJoin<TOuter, TInner, TResult>(IQueryable<TOuter>, IQueryable<TInner>, Expression<Func<TOuter, TInner, TResult>>)
Defines cross join between two sub-queries or tables.
public static IQueryable<TResult> CrossJoin<TOuter, TInner, TResult>(this IQueryable<TOuter> outer, IQueryable<TInner> inner, Expression<Func<TOuter, TInner, TResult>> resultSelector)
Parameters
outer
IQueryable<TOuter>Left join operand.
inner
IQueryable<TInner>Right join operand.
resultSelector
Expression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuter
Type of record for left join operand.
TInner
Type of record for right join operand.
TResult
The type of the result elements.
DatabaseName<T>(ITable<T>, string?)
Overrides database name with new name for current query. This call will have effect only for databases that support database name in fully-qualified table name.
Supported by: Access, DB2, MySQL, PostgreSQL, SAP HANA, SQLite, Informix, SQL Server, Sybase ASE.
Requires schema name (see SchemaName<T>(ITable<T>, string?)): DB2, SAP HANA, PostgreSQL.
PostgreSQL supports only name of current database.
public static ITable<T> DatabaseName<T>(this ITable<T> table, string? name) where T : notnull
Parameters
Returns
- ITable<T>
Table-like query source with new database name.
Type Parameters
T
Table record mapping class.
DeleteAsync<T>(IQueryable<T>, Expression<Func<T, bool>>, CancellationToken)
Executes delete operation asynchronously, using source query as initial filter for records, that should be deleted, and predicate expression as additional filter.
public static Task<int> DeleteAsync<T>(this IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<T>Query that returns records to delete.
predicate
Expression<Func<T, bool>>Filter expression, to specify what records from source should be deleted.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Mapping class for delete operation target table.
DeleteAsync<T>(IQueryable<T>, CancellationToken)
Executes delete operation asynchronously, using source query as filter for records, that should be deleted.
public static Task<int> DeleteAsync<T>(this IQueryable<T> source, CancellationToken token = default)
Parameters
source
IQueryable<T>Query that returns records to delete.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Mapping class for delete operation target table.
DeleteWhenMatchedAnd<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, TSource, bool>>)
Adds new delete operation to merge and returns new merge command with added operation. This operation removes record in target table for each record that was matched in source and target, if it was matched by operation predicate and wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> DeleteWhenMatchedAnd<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, TSource, bool>> searchCondition)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
searchCondition
Expression<Func<TTarget, TSource, bool>>Operation execution condition over target and source records.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
DeleteWhenMatched<TTarget, TSource>(IMergeableSource<TTarget, TSource>)
Adds new delete operation to merge and returns new merge command with added operation. This operation removes record in target table for each record that was matched in source and target, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> DeleteWhenMatched<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
DeleteWhenNotMatchedBySourceAnd<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, bool>>)
IMPORTANT: This operation supported only by Microsoft SQL Server. Adds new delete by source operation to merge and returns new merge command with added operation. This operation removes record in target table for each record that was matched only in target and passed filtering with operation predicate, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> DeleteWhenNotMatchedBySourceAnd<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, bool>> searchCondition)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
searchCondition
Expression<Func<TTarget, bool>>Operation execution condition over target record.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
DeleteWhenNotMatchedBySource<TTarget, TSource>(IMergeableSource<TTarget, TSource>)
IMPORTANT: This operation supported only by Microsoft SQL Server. Adds new delete by source operation to merge and returns new merge command with added operation. This operation removes record in target table for each record that was matched only in target and wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> DeleteWhenNotMatchedBySource<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
DeleteWithOutputAsync<TSource>(IQueryable<TSource>, CancellationToken)
Deletes records from source query into target table asynchronously and returns deleted records.
public static Task<TSource[]> DeleteWithOutputAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TSource[]>
Array of records.
Type Parameters
TSource
Source query record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.0+ (doesn't support multi-table statements; database limitation)
DeleteWithOutputAsync<TSource, TOutput>(IQueryable<TSource>, Expression<Func<TSource, TOutput>>, CancellationToken)
Deletes records from source query into target table asynchronously and returns deleted records.
public static Task<TOutput[]> DeleteWithOutputAsync<TSource, TOutput>(this IQueryable<TSource> source, Expression<Func<TSource, TOutput>> outputExpression, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
outputExpression
Expression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Array of records.
Type Parameters
TSource
Source query record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.0+ (doesn't support multi-table statements; database limitation)
DeleteWithOutputIntoAsync<TSource, TOutput>(IQueryable<TSource>, ITable<TOutput>, Expression<Func<TSource, TOutput>>, CancellationToken)
Deletes records from source query into target table asynchronously and outputs deleted records into outputTable
.
public static Task<int> DeleteWithOutputIntoAsync<TSource, TOutput>(this IQueryable<TSource> source, ITable<TOutput> outputTable, Expression<Func<TSource, TOutput>> outputExpression, CancellationToken token = default) where TOutput : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
DeleteWithOutputIntoAsync<TSource, TOutput>(IQueryable<TSource>, ITable<TOutput>, CancellationToken)
Deletes records from source query into target table asynchronously and outputs deleted records into outputTable
.
public static Task<int> DeleteWithOutputIntoAsync<TSource, TOutput>(this IQueryable<TSource> source, ITable<TOutput> outputTable, CancellationToken token = default) where TOutput : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
outputTable
ITable<TOutput>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
DeleteWithOutputInto<TSource, TOutput>(IQueryable<TSource>, ITable<TOutput>)
Deletes records from source query into target table and outputs deleted records into outputTable
.
public static int DeleteWithOutputInto<TSource, TOutput>(this IQueryable<TSource> source, ITable<TOutput> outputTable) where TOutput : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
outputTable
ITable<TOutput>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
DeleteWithOutputInto<TSource, TOutput>(IQueryable<TSource>, ITable<TOutput>, Expression<Func<TSource, TOutput>>)
Deletes records from source query into target table and outputs deleted records into outputTable
.
public static int DeleteWithOutputInto<TSource, TOutput>(this IQueryable<TSource> source, ITable<TOutput> outputTable, Expression<Func<TSource, TOutput>> outputExpression) where TOutput : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
DeleteWithOutput<TSource>(IQueryable<TSource>)
Deletes records from source query and returns deleted records.
public static IEnumerable<TSource> DeleteWithOutput<TSource>(this IQueryable<TSource> source)
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
Returns
- IEnumerable<TSource>
Enumeration of records.
Type Parameters
TSource
Source query record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.0+ (doesn't support multi-table statements; database limitation)
DeleteWithOutput<TSource, TOutput>(IQueryable<TSource>, Expression<Func<TSource, TOutput>>)
Deletes records from source query into target table and returns deleted records.
public static IEnumerable<TOutput> DeleteWithOutput<TSource, TOutput>(this IQueryable<TSource> source, Expression<Func<TSource, TOutput>> outputExpression)
Parameters
source
IQueryable<TSource>Source query, that returns data for delete operation.
outputExpression
Expression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Enumeration of records.
Type Parameters
TSource
Source query record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.0+ (doesn't support multi-table statements; database limitation)
Delete<T>(IQueryable<T>)
Executes delete operation, using source query as filter for records, that should be deleted.
public static int Delete<T>(this IQueryable<T> source)
Parameters
source
IQueryable<T>Query that returns records to delete.
Returns
- int
Number of deleted records.
Type Parameters
T
Mapping class for delete operation target table.
Delete<T>(IQueryable<T>, Expression<Func<T, bool>>)
Executes delete operation, using source query as initial filter for records, that should be deleted, and predicate expression as additional filter.
public static int Delete<T>(this IQueryable<T> source, Expression<Func<T, bool>> predicate)
Parameters
source
IQueryable<T>Query that returns records to delete.
predicate
Expression<Func<T, bool>>Filter expression, to specify what records from source should be deleted.
Returns
- int
Number of deleted records.
Type Parameters
T
Mapping class for delete operation target table.
DisableGuard<TKey, TElement>(IQueryable<IGrouping<TKey, TElement>>)
Disables grouping guard for particular grouping
query.
public static IQueryable<IGrouping<TKey, TElement>> DisableGuard<TKey, TElement>(this IQueryable<IGrouping<TKey, TElement>> grouping)
Parameters
grouping
IQueryable<IGrouping<TKey, TElement>>Source data query.
Returns
- IQueryable<IGrouping<TKey, TElement>>
Query with suppressed grouping guard.
Type Parameters
TKey
The type of the key of the IGrouping<TKey, TElement>.
TElement
The type of the values in the IGrouping<TKey, TElement>.
DropAsync<T>(ITable<T>, bool, CancellationToken)
Drops database table asynchronously.
public static Task<int> DropAsync<T>(this ITable<T> target, bool throwExceptionIfNotExists = true, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Dropped table.
throwExceptionIfNotExists
boolIf
false
, any exception during drop operation will be silently catched and0
returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true
.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Table record type.
Drop<T>(ITable<T>, bool)
Drops database table.
public static int Drop<T>(this ITable<T> target, bool throwExceptionIfNotExists = true) where T : notnull
Parameters
target
ITable<T>Dropped table.
throwExceptionIfNotExists
boolIf
false
, any exception during drop operation will be silently catched and0
returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true
.
Returns
- int
Number of affected records. Usually
-1
as it is not data modification operation.
Type Parameters
T
Table record type.
ElementAtAsync<TSource>(IQueryable<TSource>, Expression<Func<int>>, CancellationToken)
Selects record at specified position from source query asynchronously. If query doesn't return enough records, InvalidOperationException will be thrown.
public static Task<TSource> ElementAtAsync<TSource>(this IQueryable<TSource> source, Expression<Func<int>> index, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source query.
index
Expression<Func<int>>Expression that defines index of record to select.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TSource>
Record at specified position.
Type Parameters
TSource
Source table record type.
Exceptions
- InvalidOperationException
Source query doesn't have record with specified index.
ElementAtOrDefaultAsync<TSource>(IQueryable<TSource>, Expression<Func<int>>, CancellationToken)
Selects record at specified position from source query asynchronously.
public static Task<TSource> ElementAtOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<int>> index, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source query.
index
Expression<Func<int>>Expression that defines index of record to select.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TSource>
Record at specified position or default value, if source query doesn't have record with such index.
Type Parameters
TSource
Source table record type.
ElementAtOrDefault<TSource>(IQueryable<TSource>, Expression<Func<int>>)
Selects record at specified position from source query.
public static TSource ElementAtOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<int>> index)
Parameters
source
IQueryable<TSource>Source query.
index
Expression<Func<int>>Expression that defines index of record to select.
Returns
- TSource
Record at specified position or default value, if source query doesn't have record with such index.
Type Parameters
TSource
Source table record type.
ElementAt<TSource>(IQueryable<TSource>, Expression<Func<int>>)
Selects record at specified position from source query. If query doesn't return enough records, InvalidOperationException will be thrown.
public static TSource ElementAt<TSource>(this IQueryable<TSource> source, Expression<Func<int>> index)
Parameters
source
IQueryable<TSource>Source query.
index
Expression<Func<int>>Expression that defines index of record to select.
Returns
- TSource
Record at specified position.
Type Parameters
TSource
Source table record type.
Exceptions
- InvalidOperationException
Source query doesn't have record with specified index.
ExceptAll<TSource>(IQueryable<TSource>, IEnumerable<TSource>)
Produces the set difference of two sequences.
public static IQueryable<TSource> ExceptAll<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2)
Parameters
source1
IQueryable<TSource>An IQueryable<T> whose elements that are not also in
source2
will be returned.source2
IEnumerable<TSource>An IEnumerable<T> whose elements that also occur in the first sequence will not appear in the returned sequence.
Returns
- IQueryable<TSource>
An IQueryable<T> that contains the set difference of the two sequences.
Type Parameters
TSource
The type of the elements of the input sequences.
Exceptions
- ArgumentNullException
source1
orsource2
is null.
FullJoin<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>)
Defines full outer join between two sub-queries or tables.
public static IQueryable<TSource> FullJoin<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Parameters
source
IQueryable<TSource>Right join operand.
predicate
Expression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSource
Type of record for right join operand.
FullJoin<TOuter, TInner, TResult>(IQueryable<TOuter>, IQueryable<TInner>, Expression<Func<TOuter, TInner, bool>>, Expression<Func<TOuter, TInner, TResult>>)
Defines full outer join between two sub-queries or tables.
public static IQueryable<TResult> FullJoin<TOuter, TInner, TResult>(this IQueryable<TOuter> outer, IQueryable<TInner> inner, Expression<Func<TOuter, TInner, bool>> predicate, Expression<Func<TOuter, TInner, TResult>> resultSelector)
Parameters
outer
IQueryable<TOuter>Left join operand.
inner
IQueryable<TInner>Right join operand.
predicate
Expression<Func<TOuter, TInner, bool>>Join predicate.
resultSelector
Expression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuter
Type of record for left join operand.
TInner
Type of record for right join operand.
TResult
The type of the result elements.
GenerateTestString<T>(IQueryable<T>, bool)
Generates test source code for specified query. This method could be usefull to debug queries and attach test code to linq2db issue reports.
public static string GenerateTestString<T>(this IQueryable<T> query, bool mangleNames = false)
Parameters
query
IQueryable<T>Query to test.
mangleNames
boolShould we use real names for used types, members and namespace or generate obfuscated names.
Returns
- string
Test source code.
Type Parameters
T
HasCreateIfNotExists(TableOptions)
public static bool HasCreateIfNotExists(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasDropIfExists(TableOptions)
public static bool HasDropIfExists(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasIsGlobalTemporaryData(TableOptions)
public static bool HasIsGlobalTemporaryData(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasIsGlobalTemporaryStructure(TableOptions)
public static bool HasIsGlobalTemporaryStructure(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasIsLocalTemporaryData(TableOptions)
public static bool HasIsLocalTemporaryData(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasIsLocalTemporaryStructure(TableOptions)
public static bool HasIsLocalTemporaryStructure(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasIsTemporary(TableOptions)
public static bool HasIsTemporary(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasIsTransactionTemporaryData(TableOptions)
public static bool HasIsTransactionTemporaryData(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
HasUniqueKey<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>)
Records unique key for IQueryable. It allows sub-query to be optimized out in LEFT JOIN if columns from sub-query are not used in final projection and predicate.
public static IQueryable<TSource> HasUniqueKey<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
Parameters
source
IQueryable<TSource>Source data query.
keySelector
Expression<Func<TSource, TKey>>A function to specify which fields are unique.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSource
Source query record type.
TKey
Key type.
Having<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>)
Filters source query using HAVING SQL clause. In general you don't need to use this method as linq2db is able to propely identify current context for Where<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>) method and generate HAVING clause. More details.
public static IQueryable<TSource> Having<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Parameters
source
IQueryable<TSource>Source query to filter.
predicate
Expression<Func<TSource, bool>>Filtering expression.
Returns
- IQueryable<TSource>
Filtered query.
Type Parameters
TSource
Source query record type.
IgnoreFilters<TSource>(IQueryable<TSource>, params Type[])
Disables Query Filters in current query.
public static IQueryable<TSource> IgnoreFilters<TSource>(this IQueryable<TSource> source, params Type[] entityTypes)
Parameters
source
IQueryable<TSource>Source query.
entityTypes
Type[]Optional types with which filters should be disabled.
Returns
- IQueryable<TSource>
Query with disabled filters.
Type Parameters
TSource
Source query record type.
IndexHint<TSource>(ITable<TSource>, string)
Adds an index hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.IndexHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.IndexHint, typeof(HintExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.IndexHint, typeof(HintExtensionBuilder))]
public static ITable<TSource> IndexHint<TSource>(this ITable<TSource> table, string hint) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- ITable<TSource>
Table-like query source with index hints.
Type Parameters
TSource
Table record mapping class.
IndexHint<TSource, TParam>(ITable<TSource>, string, TParam)
Adds an index hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.IndexHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.IndexHint, typeof(HintWithParameterExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.IndexHint, typeof(HintWithParameterExtensionBuilder))]
public static ITable<TSource> IndexHint<TSource, TParam>(this ITable<TSource> table, string hint, TParam hintParameter) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameter
TParamTable hint parameter.
Returns
- ITable<TSource>
Table-like query source with index hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
IndexHint<TSource, TParam>(ITable<TSource>, string, params TParam[])
Adds an index hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.IndexHint, typeof(TableSpecHintExtensionBuilder), " ", " ")]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.IndexHint, typeof(HintWithParametersExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.IndexHint, typeof(HintWithParametersExtensionBuilder))]
public static ITable<TSource> IndexHint<TSource, TParam>(this ITable<TSource> table, string hint, params TParam[] hintParameters) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameters
TParam[]Table hint parameters.
Returns
- ITable<TSource>
Table-like query source with index hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
InlineParameters<TSource>(IQueryable<TSource>)
Inline parameters in query which can be converted to SQL Literal.
public static IQueryable<TSource> InlineParameters<TSource>(this IQueryable<TSource> source)
Parameters
source
IQueryable<TSource>Source data query.
Returns
- IQueryable<TSource>
Query with inlined parameters.
Type Parameters
TSource
Source query record type.
InnerJoin<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>)
Defines inner join between two sub-queries or tables.
public static IQueryable<TSource> InnerJoin<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Parameters
source
IQueryable<TSource>Right join operand.
predicate
Expression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSource
Type of record for right join operand.
InnerJoin<TOuter, TInner, TResult>(IQueryable<TOuter>, IQueryable<TInner>, Expression<Func<TOuter, TInner, bool>>, Expression<Func<TOuter, TInner, TResult>>)
Defines inner or outer join between two sub-queries or tables.
public static IQueryable<TResult> InnerJoin<TOuter, TInner, TResult>(this IQueryable<TOuter> outer, IQueryable<TInner> inner, Expression<Func<TOuter, TInner, bool>> predicate, Expression<Func<TOuter, TInner, TResult>> resultSelector)
Parameters
outer
IQueryable<TOuter>Left join operand.
inner
IQueryable<TInner>Right join operand.
predicate
Expression<Func<TOuter, TInner, bool>>Join predicate.
resultSelector
Expression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuter
Type of record for left join operand.
TInner
Type of record for right join operand.
TResult
The type of the result elements.
InsertAsync<T>(ITable<T>, Expression<Func<T>>, CancellationToken)
Inserts single record into target table asynchronously.
public static Task<int> InsertAsync<T>(this ITable<T> target, Expression<Func<T>> setter, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Inserted record type.
InsertAsync<T>(IValueInsertable<T>, CancellationToken)
Executes insert query asynchronously.
public static Task<int> InsertAsync<T>(this IValueInsertable<T> source, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table record type.
InsertAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, CancellationToken)
Executes configured insert query asynchronously.
public static Task<int> InsertAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, CancellationToken token = default)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Inserts records from source query into target table asynchronously.
public static Task<int> InsertAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertOrUpdateAsync<T>(ITable<T>, Expression<Func<T>>, Expression<Func<T, T?>>?, Expression<Func<T>>, CancellationToken)
Asynchronously inserts new record into target table or updates existing record if record with the same key value already exists in target table.
When null
value or expression without field setters passed to onDuplicateKeyUpdateSetter
, this method
implements INSERT IF NOT EXISTS
logic.
public static Task<int> InsertOrUpdateAsync<T>(this ITable<T> target, Expression<Func<T>> insertSetter, Expression<Func<T, T?>>? onDuplicateKeyUpdateSetter, Expression<Func<T>> keySelector, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
insertSetter
Expression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetter
Expression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
keySelector
Expression<Func<T>>Key fields selector to specify what fields and values must be used as key fields for selection between insert and update operations. Expression supports only target table record new expression with field initializers for each key field. Assigned key field value will be used as key value by operation type selector.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Table record type.
InsertOrUpdateAsync<T>(ITable<T>, Expression<Func<T>>, Expression<Func<T, T?>>?, CancellationToken)
Asynchronously inserts new record into target table or updates existing record if record with the same primary key value already exists in target table.
When null
value or expression without field setters passed to onDuplicateKeyUpdateSetter
, this method
implements INSERT IF NOT EXISTS
logic.
public static Task<int> InsertOrUpdateAsync<T>(this ITable<T> target, Expression<Func<T>> insertSetter, Expression<Func<T, T?>>? onDuplicateKeyUpdateSetter, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
insertSetter
Expression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetter
Expression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Table record type.
InsertOrUpdate<T>(ITable<T>, Expression<Func<T>>, Expression<Func<T, T?>>?)
Inserts new record into target table or updates existing record if record with the same primary key value already exists in target table.
When null
value or expression without field setters passed to onDuplicateKeyUpdateSetter
, this method
implements INSERT IF NOT EXISTS
logic.
public static int InsertOrUpdate<T>(this ITable<T> target, Expression<Func<T>> insertSetter, Expression<Func<T, T?>>? onDuplicateKeyUpdateSetter) where T : notnull
Parameters
target
ITable<T>Target table.
insertSetter
Expression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetter
Expression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
Returns
- int
Number of affected records.
Type Parameters
T
Table record type.
InsertOrUpdate<T>(ITable<T>, Expression<Func<T>>, Expression<Func<T, T?>>?, Expression<Func<T>>)
Inserts new record into target table or updates existing record if record with the same key value already exists in target table.
When null
value or expression without field setters passed to onDuplicateKeyUpdateSetter
, this method
implements INSERT IF NOT EXISTS
logic.
public static int InsertOrUpdate<T>(this ITable<T> target, Expression<Func<T>> insertSetter, Expression<Func<T, T?>>? onDuplicateKeyUpdateSetter, Expression<Func<T>> keySelector) where T : notnull
Parameters
target
ITable<T>Target table.
insertSetter
Expression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetter
Expression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
keySelector
Expression<Func<T>>Key fields selector to specify what fields and values must be used as key fields for selection between insert and update operations. Expression supports only target table record new expression with field initializers for each key field. Assigned key field value will be used as key value by operation type selector.
Returns
- int
Number of affected records.
Type Parameters
T
Table record type.
InsertWhenNotMatchedAnd<TTarget>(IMergeableSource<TTarget, TTarget>, Expression<Func<TTarget, bool>>)
Adds new insert operation to merge and returns new merge command with added operation. This operation inserts new record to target table using data from the same fields of source record for each new record from source that passes filtering with specified predicate, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TTarget> InsertWhenNotMatchedAnd<TTarget>(this IMergeableSource<TTarget, TTarget> merge, Expression<Func<TTarget, bool>> searchCondition)
Parameters
merge
IMergeableSource<TTarget, TTarget>Merge command builder interface.
searchCondition
Expression<Func<TTarget, bool>>Operation execution condition over source record.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target and source records type.
InsertWhenNotMatchedAnd<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TSource, bool>>, Expression<Func<TSource, TTarget>>)
Adds new insert operation to merge and returns new merge command with added operation. This operation inserts new record to target table using user-defined values for target columns for each new record from source that passes filtering with specified predicate, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> InsertWhenNotMatchedAnd<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TSource, bool>> searchCondition, Expression<Func<TSource, TTarget>> setter)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
searchCondition
Expression<Func<TSource, bool>>Operation execution condition over source record.
setter
Expression<Func<TSource, TTarget>>Create record expression using source record. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
InsertWhenNotMatched<TTarget>(IMergeableSource<TTarget, TTarget>)
Adds new insert operation to merge and returns new merge command with added operation. This operation inserts new record to target table using data from the same fields of source record for each new record from source, not processed by previous operations.
public static IMergeable<TTarget, TTarget> InsertWhenNotMatched<TTarget>(this IMergeableSource<TTarget, TTarget> merge)
Parameters
merge
IMergeableSource<TTarget, TTarget>Merge command builder interface.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target and source records type.
InsertWhenNotMatched<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TSource, TTarget>>)
Adds new insert operation to merge and returns new merge command with added operation. This operation inserts new record to target table using user-defined values for target columns for each new record from source, not processed by previous operations.
public static IMergeable<TTarget, TSource> InsertWhenNotMatched<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TSource, TTarget>> setter)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
setter
Expression<Func<TSource, TTarget>>Create record expression using source record. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
InsertWithDecimalIdentityAsync<T>(ITable<T>, Expression<Func<T>>, CancellationToken)
Inserts single record into target table asynchronously and returns identity value of inserted record as decimal value.
public static Task<decimal> InsertWithDecimalIdentityAsync<T>(this ITable<T> target, Expression<Func<T>> setter, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Inserted record type.
InsertWithDecimalIdentityAsync<T>(IValueInsertable<T>, CancellationToken)
Executes insert query asynchronously and returns identity value of inserted record as decimal value.
public static Task<decimal?> InsertWithDecimalIdentityAsync<T>(this IValueInsertable<T> source, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table record type.
InsertWithDecimalIdentityAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, CancellationToken)
Executes configured insert query asynchronously and returns identity value of last inserted record as decimal value.
public static Task<decimal?> InsertWithDecimalIdentityAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, CancellationToken token = default)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithDecimalIdentityAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Inserts records from source query into target table asynchronously and returns identity value of last inserted record as decimal value.
public static Task<decimal?> InsertWithDecimalIdentityAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithDecimalIdentity<T>(ITable<T>, Expression<Func<T>>)
Inserts single record into target table and returns identity value of inserted record as decimal value.
public static decimal InsertWithDecimalIdentity<T>(this ITable<T> target, Expression<Func<T>> setter) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- decimal
Inserted record's identity value.
Type Parameters
T
Inserted record type.
InsertWithDecimalIdentity<T>(IValueInsertable<T>)
Executes insert query and returns identity value of inserted record as decimal value.
public static decimal? InsertWithDecimalIdentity<T>(this IValueInsertable<T> source)
Parameters
source
IValueInsertable<T>Insert query.
Returns
- decimal?
Inserted record's identity value.
Type Parameters
T
Target table record type.
InsertWithDecimalIdentity<TSource, TTarget>(ISelectInsertable<TSource, TTarget>)
Executes configured insert query and returns identity value of last inserted record as decimal value.
public static decimal? InsertWithDecimalIdentity<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
Returns
- decimal?
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithDecimalIdentity<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Inserts records from source query into target table and returns identity value of last inserted record as decimal value.
public static decimal? InsertWithDecimalIdentity<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
Returns
- decimal?
Last inserted record's identity value.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithIdentityAsync<T>(ITable<T>, Expression<Func<T>>, CancellationToken)
Inserts single record into target table asynchronously and returns identity value of inserted record.
public static Task<object> InsertWithIdentityAsync<T>(this ITable<T> target, Expression<Func<T>> setter, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Inserted record type.
InsertWithIdentityAsync<T>(IValueInsertable<T>, CancellationToken)
Executes insert query asynchronously and returns identity value of inserted record.
public static Task<object> InsertWithIdentityAsync<T>(this IValueInsertable<T> source, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table record type.
InsertWithIdentityAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, CancellationToken)
Executes configured insert query asynchronously and returns identity value of last inserted record.
public static Task<object> InsertWithIdentityAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, CancellationToken token = default)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithIdentityAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Inserts records from source query into target table asynchronously and returns identity value of last inserted record.
public static Task<object> InsertWithIdentityAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithIdentity<T>(ITable<T>, Expression<Func<T>>)
Inserts single record into target table and returns identity value of inserted record.
public static object InsertWithIdentity<T>(this ITable<T> target, Expression<Func<T>> setter) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- object
Inserted record's identity value.
Type Parameters
T
Inserted record type.
InsertWithIdentity<T>(IValueInsertable<T>)
Executes insert query and returns identity value of inserted record.
public static object InsertWithIdentity<T>(this IValueInsertable<T> source)
Parameters
source
IValueInsertable<T>Insert query.
Returns
- object
Inserted record's identity value.
Type Parameters
T
Target table record type.
InsertWithIdentity<TSource, TTarget>(ISelectInsertable<TSource, TTarget>)
Executes configured insert query and returns identity value of last inserted record.
public static object InsertWithIdentity<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
Returns
- object
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithIdentity<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Inserts records from source query into target table and returns identity value of last inserted record.
public static object InsertWithIdentity<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
Returns
- object
Last inserted record's identity value.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithInt32IdentityAsync<T>(ITable<T>, Expression<Func<T>>, CancellationToken)
Inserts single record into target table asynchronously and returns identity value of inserted record as int value.
public static Task<int> InsertWithInt32IdentityAsync<T>(this ITable<T> target, Expression<Func<T>> setter, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Inserted record type.
InsertWithInt32IdentityAsync<T>(IValueInsertable<T>, CancellationToken)
Executes insert query asynchronously and returns identity value of inserted record as int value.
public static Task<int?> InsertWithInt32IdentityAsync<T>(this IValueInsertable<T> source, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table record type.
InsertWithInt32IdentityAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, CancellationToken)
Executes configured insert query asynchronously and returns identity value of last inserted record as int value.
public static Task<int?> InsertWithInt32IdentityAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, CancellationToken token = default)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithInt32IdentityAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Inserts records from source query into target table asynchronously and returns identity value of last inserted record as int value.
public static Task<int?> InsertWithInt32IdentityAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithInt32Identity<T>(ITable<T>, Expression<Func<T>>)
Inserts single record into target table and returns identity value of inserted record as int value.
public static int InsertWithInt32Identity<T>(this ITable<T> target, Expression<Func<T>> setter) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- int
Inserted record's identity value.
Type Parameters
T
Inserted record type.
InsertWithInt32Identity<T>(IValueInsertable<T>)
Executes insert query and returns identity value of inserted record as int value.
public static int? InsertWithInt32Identity<T>(this IValueInsertable<T> source)
Parameters
source
IValueInsertable<T>Insert query.
Returns
- int?
Inserted record's identity value.
Type Parameters
T
Target table record type.
InsertWithInt32Identity<TSource, TTarget>(ISelectInsertable<TSource, TTarget>)
Executes configured insert query and returns identity value of last inserted record as int value.
public static int? InsertWithInt32Identity<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
Returns
- int?
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithInt32Identity<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Inserts records from source query into target table and returns identity value of last inserted record as int value.
public static int? InsertWithInt32Identity<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
Returns
- int?
Last inserted record's identity value.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithInt64IdentityAsync<T>(ITable<T>, Expression<Func<T>>, CancellationToken)
Inserts single record into target table asynchronously and returns identity value of inserted record as long value.
public static Task<long> InsertWithInt64IdentityAsync<T>(this ITable<T> target, Expression<Func<T>> setter, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Inserted record type.
InsertWithInt64IdentityAsync<T>(IValueInsertable<T>, CancellationToken)
Executes insert query asynchronously and returns identity value of inserted record as long value.
public static Task<long?> InsertWithInt64IdentityAsync<T>(this IValueInsertable<T> source, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Target table record type.
InsertWithInt64IdentityAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, CancellationToken)
Executes configured insert query asynchronously and returns identity value of last inserted record as long value.
public static Task<long?> InsertWithInt64IdentityAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, CancellationToken token = default)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithInt64IdentityAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Inserts records from source query into target table asynchronously and returns identity value of last inserted record as long value.
public static Task<long?> InsertWithInt64IdentityAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithInt64Identity<T>(ITable<T>, Expression<Func<T>>)
Inserts single record into target table and returns identity value of inserted record as long value.
public static long InsertWithInt64Identity<T>(this ITable<T> target, Expression<Func<T>> setter) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- long
Inserted record's identity value.
Type Parameters
T
Inserted record type.
InsertWithInt64Identity<T>(IValueInsertable<T>)
Executes insert query and returns identity value of inserted record as long value.
public static long? InsertWithInt64Identity<T>(this IValueInsertable<T> source)
Parameters
source
IValueInsertable<T>Insert query.
Returns
- long?
Inserted record's identity value.
Type Parameters
T
Target table record type.
InsertWithInt64Identity<TSource, TTarget>(ISelectInsertable<TSource, TTarget>)
Executes configured insert query and returns identity value of last inserted record as long value.
public static long? InsertWithInt64Identity<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
Returns
- long?
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
InsertWithInt64Identity<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Inserts records from source query into target table and returns identity value of last inserted record as long value.
public static long? InsertWithInt64Identity<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
Returns
- long?
Last inserted record's identity value.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
InsertWithOutputAsync<TTarget>(ITable<TTarget>, Expression<Func<TTarget>>, CancellationToken)
Inserts single record into target table asynchronously and returns inserted record.
public static Task<TTarget> InsertWithOutputAsync<TTarget>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget>
Inserted record.
Type Parameters
TTarget
Inserted record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<TTarget>(ITable<TTarget>, TTarget, CancellationToken)
Inserts single record into target table asynchronously and returns inserted record.
public static Task<TTarget> InsertWithOutputAsync<TTarget>(this ITable<TTarget> target, TTarget obj, CancellationToken token = default) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
obj
TTargetObject with data to insert.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget>
Inserted record.
Type Parameters
TTarget
Inserted record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<T>(IValueInsertable<T>, CancellationToken)
Inserts single record into target table asynchronously and returns inserted record.
public static Task<T> InsertWithOutputAsync<T>(this IValueInsertable<T> source, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<T>
Inserted record.
Type Parameters
T
Target table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<TTarget, TOutput>(ITable<TTarget>, Expression<Func<TTarget>>, Expression<Func<TTarget, TOutput>>, CancellationToken)
Inserts single record into target table asynchronously and returns inserted record.
public static Task<TOutput> InsertWithOutputAsync<TTarget, TOutput>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, Expression<Func<TTarget, TOutput>> outputExpression, CancellationToken token = default) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput>
Inserted record.
Type Parameters
TTarget
Inserted record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, CancellationToken)
Executes configured insert query asynchronously and returns inserted record.
public static Task<TTarget> InsertWithOutputAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, CancellationToken token = default)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget>
Inserted record.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<T, TOutput>(IValueInsertable<T>, Expression<Func<T, TOutput>>, CancellationToken)
Inserts single record into target table asynchronously and returns inserted record.
public static Task<TOutput> InsertWithOutputAsync<T, TOutput>(this IValueInsertable<T> source, Expression<Func<T, TOutput>> outputExpression, CancellationToken token = default)
Parameters
source
IValueInsertable<T>Insert query.
outputExpression
Expression<Func<T, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput>
Inserted record.
Type Parameters
T
Target table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Inserts records from source query into target table asynchronously and returns newly created records.
public static Task<TTarget[]> InsertWithOutputAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget[]>
Array of records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputAsync<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, Expression<Func<TTarget, TOutput>>, CancellationToken)
Inserts records from source query into target table asynchronously and returns newly created records.
public static Task<TOutput[]> InsertWithOutputAsync<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, Expression<Func<TTarget, TOutput>> outputExpression, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Array of records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutputIntoAsync<TTarget>(ITable<TTarget>, Expression<Func<TTarget>>, ITable<TTarget>, CancellationToken)
Inserts single record into target table asynchronously and outputs that record into outputTable
.
public static Task<int> InsertWithOutputIntoAsync<TTarget>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, ITable<TTarget> outputTable, CancellationToken token = default) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget
Inserted record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputIntoAsync<TTarget, TOutput>(ITable<TTarget>, Expression<Func<TTarget>>, ITable<TOutput>, Expression<Func<TTarget, TOutput>>, CancellationToken)
Inserts single record into target table asynchronously and outputs that record into outputTable
.
public static Task<int> InsertWithOutputIntoAsync<TTarget, TOutput>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TTarget, TOutput>> outputExpression, CancellationToken token = default) where TTarget : notnull where TOutput : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget
Inserted record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputIntoAsync<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, ITable<TTarget>, CancellationToken)
Executes configured insert query asynchronously and returns inserted record.
public static Task<int> InsertWithOutputIntoAsync<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, ITable<TTarget> outputTable, CancellationToken token = default) where TTarget : notnull
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
outputTable
ITable<TTarget>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputIntoAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TTarget>, CancellationToken)
Inserts records from source query into target table asynchronously and outputs inserted records into outputTable
.
public static Task<int> InsertWithOutputIntoAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TTarget> outputTable, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputIntoAsync<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TOutput>, Expression<Func<TTarget, TOutput>>, CancellationToken)
Inserts records from source query into target table asynchronously and outputs inserted records into outputTable
.
public static Task<int> InsertWithOutputIntoAsync<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TTarget, TOutput>> outputExpression, CancellationToken token = default) where TTarget : notnull where TOutput : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputInto<TTarget>(ITable<TTarget>, Expression<Func<TTarget>>, ITable<TTarget>)
Inserts single record into target table and outputs that record into outputTable
.
public static int InsertWithOutputInto<TTarget>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, ITable<TTarget> outputTable) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TTarget
Inserted record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputInto<TTarget, TOutput>(ITable<TTarget>, Expression<Func<TTarget>>, ITable<TOutput>, Expression<Func<TTarget, TOutput>>)
Inserts single record into target table and outputs that record into outputTable
.
public static int InsertWithOutputInto<TTarget, TOutput>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TTarget, TOutput>> outputExpression) where TTarget : notnull where TOutput : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TTarget
Inserted record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputInto<TSource, TTarget>(ISelectInsertable<TSource, TTarget>, ITable<TTarget>)
Executes configured insert query and returns inserted record.
public static int InsertWithOutputInto<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source, ITable<TTarget> outputTable) where TTarget : notnull
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
outputTable
ITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputInto<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TTarget>)
Inserts records from source query into target table and outputs newly created records into outputTable
.
public static int InsertWithOutputInto<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TTarget> outputTable) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutputInto<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TOutput>, Expression<Func<TTarget, TOutput>>)
Inserts records from source query into target table and outputs inserted records into outputTable
.
public static int InsertWithOutputInto<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TTarget, TOutput>> outputExpression) where TTarget : notnull where TOutput : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
InsertWithOutput<TTarget>(ITable<TTarget>, Expression<Func<TTarget>>)
Inserts single record into target table and returns inserted record.
public static TTarget InsertWithOutput<TTarget>(this ITable<TTarget> target, Expression<Func<TTarget>> setter) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- TTarget
Inserted record.
Type Parameters
TTarget
Inserted record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<TTarget>(ITable<TTarget>, TTarget)
Inserts single record into target table and returns inserted record.
public static TTarget InsertWithOutput<TTarget>(this ITable<TTarget> target, TTarget obj) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
obj
TTargetObject with data to insert.
Returns
- TTarget
Inserted record.
Type Parameters
TTarget
Inserted record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<T>(IValueInsertable<T>)
Inserts single record into target table and returns inserted record.
public static T InsertWithOutput<T>(this IValueInsertable<T> source)
Parameters
source
IValueInsertable<T>Insert query.
Returns
- T
Inserted record.
Type Parameters
T
Target table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<TTarget, TOutput>(ITable<TTarget>, Expression<Func<TTarget>>, Expression<Func<TTarget, TOutput>>)
Inserts single record into target table and returns inserted record.
public static TOutput InsertWithOutput<TTarget, TOutput>(this ITable<TTarget> target, Expression<Func<TTarget>> setter, Expression<Func<TTarget, TOutput>> outputExpression) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
setter
Expression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- TOutput
Inserted record.
Type Parameters
TTarget
Inserted record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<TSource, TTarget>(ISelectInsertable<TSource, TTarget>)
Executes configured insert query and returns inserted record.
public static TTarget InsertWithOutput<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
Returns
- TTarget
Inserted record.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<T, TOutput>(IValueInsertable<T>, Expression<Func<T, TOutput>>)
Inserts single record into target table and returns inserted record.
public static TOutput InsertWithOutput<T, TOutput>(this IValueInsertable<T> source, Expression<Func<T, TOutput>> outputExpression)
Parameters
source
IValueInsertable<T>Insert query.
outputExpression
Expression<Func<T, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- TOutput
Inserted record.
Type Parameters
T
Target table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Inserts records from source query into target table and returns newly created records.
public static IEnumerable<TTarget> InsertWithOutput<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
Returns
- IEnumerable<TTarget>
Enumeration of records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
InsertWithOutput<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, Expression<Func<TTarget, TOutput>>)
Inserts records from source query into target table and returns newly created records.
public static IEnumerable<TOutput> InsertWithOutput<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, Expression<Func<TTarget, TOutput>> outputExpression) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Enumeration of records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL
- SQLite 3.35+
- MariaDB 10.5+
Insert<T>(ITable<T>, Expression<Func<T>>)
Inserts single record into target table.
public static int Insert<T>(this ITable<T> target, Expression<Func<T>> setter) where T : notnull
Parameters
target
ITable<T>Target table.
setter
Expression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
T
Inserted record type.
Insert<T>(IValueInsertable<T>)
Executes insert query.
public static int Insert<T>(this IValueInsertable<T> source)
Parameters
source
IValueInsertable<T>Insert query.
Returns
- int
Number of affected records.
Type Parameters
T
Target table record type.
Insert<TSource, TTarget>(ISelectInsertable<TSource, TTarget>)
Executes configured insert query.
public static int Insert<TSource, TTarget>(this ISelectInsertable<TSource, TTarget> source)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type.
Insert<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Inserts records from source query into target table.
public static int Insert<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source query, that returns data for insert operation.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table record type
IntersectAll<TSource>(IQueryable<TSource>, IEnumerable<TSource>)
Produces the set intersection of two sequences.
public static IQueryable<TSource> IntersectAll<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2)
Parameters
source1
IQueryable<TSource>A sequence whose elements that also appear in
source2
are returned.source2
IEnumerable<TSource>A sequence whose elements that also appear in the first sequence are returned.
Returns
- IQueryable<TSource>
A sequence that contains the set intersection of the two sequences.
Type Parameters
TSource
The type of the elements of the input sequences.
Exceptions
- ArgumentNullException
source1
orsource2
is null.
Into<T>(IDataContext, ITable<T>)
Starts insert operation LINQ query definition.
public static IValueInsertable<T> Into<T>(this IDataContext dataContext, ITable<T> target) where T : notnull
Parameters
dataContext
IDataContextDatabase connection context.
target
ITable<T>Target table.
Returns
- IValueInsertable<T>
Insertable source query.
Type Parameters
T
Target table mapping class.
Into<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>)
Converts LINQ query into insert query with source query data as data to insert.
public static ISelectInsertable<TSource, TTarget> Into<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
Returns
- ISelectInsertable<TSource, TTarget>
Insertable source query.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
IsSet(TableOptions)
public static bool IsSet(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
IsTemporaryOptionSet(TableOptions)
public static bool IsTemporaryOptionSet(this TableOptions tableOptions)
Parameters
tableOptions
TableOptions
Returns
JoinHint<TSource>(IQueryable<TSource>, string)
Adds a join hint to a generated query.
[Sql.QueryExtension(Sql.QueryExtensionScope.JoinHint, typeof(NoneExtensionBuilder))]
public static IQueryable<TSource> JoinHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with join hints.
Type Parameters
TSource
Table record mapping class.
Join<TSource>(IQueryable<TSource>, SqlJoinType, Expression<Func<TSource, bool>>)
Defines inner or outer join between two sub-queries or tables.
public static IQueryable<TSource> Join<TSource>(this IQueryable<TSource> source, SqlJoinType joinType, Expression<Func<TSource, bool>> predicate)
Parameters
source
IQueryable<TSource>Right join operand.
joinType
SqlJoinTypeType of join.
predicate
Expression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSource
Type of record for right join operand.
Join<TOuter, TInner, TResult>(IQueryable<TOuter>, IQueryable<TInner>, SqlJoinType, Expression<Func<TOuter, TInner, bool>>, Expression<Func<TOuter, TInner, TResult>>)
Defines inner or outer join between two sub-queries or tables.
public static IQueryable<TResult> Join<TOuter, TInner, TResult>(this IQueryable<TOuter> outer, IQueryable<TInner> inner, SqlJoinType joinType, Expression<Func<TOuter, TInner, bool>> predicate, Expression<Func<TOuter, TInner, TResult>> resultSelector)
Parameters
outer
IQueryable<TOuter>Left join operand.
inner
IQueryable<TInner>Right join operand.
joinType
SqlJoinTypeType of join.
predicate
Expression<Func<TOuter, TInner, bool>>Join predicate.
resultSelector
Expression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuter
Type of record for left join operand.
TInner
Type of record for right join operand.
TResult
The type of the result elements.
LeftJoin<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>)
Defines left outer join between two sub-queries or tables.
public static IQueryable<TSource> LeftJoin<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Parameters
source
IQueryable<TSource>Right join operand.
predicate
Expression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSource
Type of record for right join operand.
LeftJoin<TOuter, TInner, TResult>(IQueryable<TOuter>, IQueryable<TInner>, Expression<Func<TOuter, TInner, bool>>, Expression<Func<TOuter, TInner, TResult>>)
Defines left outer join between two sub-queries or tables.
public static IQueryable<TResult> LeftJoin<TOuter, TInner, TResult>(this IQueryable<TOuter> outer, IQueryable<TInner> inner, Expression<Func<TOuter, TInner, bool>> predicate, Expression<Func<TOuter, TInner, TResult>> resultSelector)
Parameters
outer
IQueryable<TOuter>Left join operand.
inner
IQueryable<TInner>Right join operand.
predicate
Expression<Func<TOuter, TInner, bool>>Join predicate.
resultSelector
Expression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuter
Type of record for left join operand.
TInner
Type of record for right join operand.
TResult
The type of the result elements.
LoadWithAsTable<T>(ITable<T>, Expression<Func<T, object?>>)
Specifies associations, that should be loaded for each loaded record from current table.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
Some usage examples:
// loads records from Table1 with Reference association loaded for each Table1 record
db.Table1.LoadWithAsTable(r => r.Reference);
// loads records from Table1 with Reference1 association loaded for each Table1 record
// loads records from Reference2 association for each loaded Reference1 record
db.Table1.LoadWithAsTable(r => r.Reference1.Reference2);
// loads records from Table1 with References collection association loaded for each Table1 record
db.Table1.LoadWithAsTable(r => r.References);
// loads records from Table1 with Reference1 collection association loaded for each Table1 record
// loads records from Reference2 collection association for each loaded Reference1 record
// loads records from Reference3 association for each loaded Reference2 record
// note that a way you access collection association record (by index, using First() method) doesn't affect
// query results and always select all records
db.Table1.LoadWithAsTable(r => r.References1[0].References2.First().Reference3);
public static ITable<T> LoadWithAsTable<T>(this ITable<T> table, Expression<Func<T, object?>> selector) where T : notnull
Parameters
table
ITable<T>Table-like query source.
selector
Expression<Func<T, object>>Association selection expression.
Returns
- ITable<T>
Table-like query source.
Type Parameters
T
Table record mapping class.
LoadWith<TEntity, TProperty>(IQueryable<TEntity>, Expression<Func<TEntity, IEnumerable<TProperty>?>>, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>)
Specifies associations that should be loaded for each loaded record from current table.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
loadFunc
parameter could be used to define additional association loading logic like filters or loading of more associations.
public static ILoadWithQueryable<TEntity, TProperty> LoadWith<TEntity, TProperty>(this IQueryable<TEntity> source, Expression<Func<TEntity, IEnumerable<TProperty>?>> selector, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>> loadFunc) where TEntity : class
Parameters
source
IQueryable<TEntity>The source query.
selector
Expression<Func<TEntity, IEnumerable<TProperty>>>A lambda expression representing navigation property to be included (
t => t.Property1
).loadFunc
Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>Defines additional logic for association load query.
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TProperty
Type of the related entity to be included.
Examples
Following query loads records from Table1 with Reference association, loaded for each Table1 record.
db.Table1.LoadWith(r => r.Reference);
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Following query loads records from Table1 with References collection association loaded for each Table1 record.
db.Table1.LoadWith(r => r.References);
Following query loads records from Table1 with: - Reference1 collection association loaded for each Table1 record; - Reference2 collection association for each loaded Reference1 record; - Reference3 association for each loaded Reference2 record.
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
Following query loads records from Table1 with References collection association loaded for each Table1 record, where References record contains only records without "exclude" text in Name property.
db.Table1.LoadWith(r => r.References, r => r.Where(rr => !rr.Name.Contains("exclude")));
Following query loads records from Table1 with References1 collection association loaded for each Table1 record, where References1 record also load Reference2 association.
db.Table1.LoadWith(r => r.References1, r => r.LoadWith(rr => rr.Reference2));
LoadWith<TEntity, TProperty>(IQueryable<TEntity>, Expression<Func<TEntity, TProperty?>>)
Specifies associations that should be loaded for each loaded record from current table.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
public static ILoadWithQueryable<TEntity, TProperty> LoadWith<TEntity, TProperty>(this IQueryable<TEntity> source, Expression<Func<TEntity, TProperty?>> selector) where TEntity : class
Parameters
source
IQueryable<TEntity>The source query.
selector
Expression<Func<TEntity, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1
).
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TProperty
Type of the related entity to be included.
Examples
Following query loads records from Table1 with Reference association, loaded for each Table1 record.
db.Table1.LoadWith(r => r.Reference);
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Following query loads records from Table1 with References collection association loaded for each Table1 record.
db.Table1.LoadWith(r => r.References);
Following query loads records from Table1 with References collection association loaded for each Table1 record. Also it limits loaded records.
db.Table1.LoadWith(r => r.References.Where(e => !e.IsDeleted).Take(10));
Following query loads records from Table1 with: - Reference1 collection association loaded for each Table1 record; - Reference2 collection association for each loaded Reference1 record; - Reference3 association for each loaded Reference2 record.
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
LoadWith<TEntity, TProperty>(IQueryable<TEntity>, Expression<Func<TEntity, TProperty?>>, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>)
Specifies associations that should be loaded for each loaded record from current table.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
loadFunc
parameter could be used to define additional association loading logic like filters or loading of more associations.
public static ILoadWithQueryable<TEntity, TProperty> LoadWith<TEntity, TProperty>(this IQueryable<TEntity> source, Expression<Func<TEntity, TProperty?>> selector, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>> loadFunc) where TEntity : class
Parameters
source
IQueryable<TEntity>The source query.
selector
Expression<Func<TEntity, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1
).loadFunc
Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>Defines additional logic for association load query.
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TProperty
Type of the related entity to be included.
Examples
Following query loads records from Table1 with Reference association, loaded for each Table1 record.
db.Table1.LoadWith(r => r.Reference);
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Following query loads records from Table1 with References collection association loaded for each Table1 record.
db.Table1.LoadWith(r => r.References);
Following query loads records from Table1 with: - Reference1 collection association loaded for each Table1 record; - Reference2 collection association for each loaded Reference1 record; - Reference3 association for each loaded Reference2 record.
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
Following query loads records from Table1 with References collection association loaded for each Table1 record, where References record contains only records without "exclude" text in Name property.
db.Table1.LoadWith(r => r.References, r => r.Where(rr => !rr.Name.Contains("exclude")));
Following query loads records from Table1 with References1 collection association loaded for each Table1 record, where References1 record also load Reference2 association.
db.Table1.LoadWith(r => r.References1, r => r.LoadWith(rr => rr.Reference2));
MergeAsync<TTarget, TSource>(IMergeable<TTarget, TSource>, CancellationToken)
Executes merge command and returns total number of target records, affected by merge operations.
public static Task<int> MergeAsync<TTarget, TSource>(this IMergeable<TTarget, TSource> merge, CancellationToken token = default)
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
token
CancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTarget
Target record type.
TSource
Source record type.
MergeInto<TTarget, TSource>(IQueryable<TSource>, ITable<TTarget>)
Starts merge operation definition from source query.
public static IMergeableOn<TTarget, TSource> MergeInto<TTarget, TSource>(this IQueryable<TSource> source, ITable<TTarget> target) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
MergeInto<TTarget, TSource>(IQueryable<TSource>, ITable<TTarget>, string)
Starts merge operation definition from source query.
public static IMergeableOn<TTarget, TSource> MergeInto<TTarget, TSource>(this IQueryable<TSource> source, ITable<TTarget> target, string hint) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
hint
stringDatabase-specific merge hint.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
MergeInto<TTarget, TSource>(IQueryable<TSource>, IQueryable<TTarget>)
Starts merge operation definition from source query.
public static IMergeableOn<TTarget, TSource> MergeInto<TTarget, TSource>(this IQueryable<TSource> source, IQueryable<TTarget> target)
Parameters
source
IQueryable<TSource>Source data query.
target
IQueryable<TTarget>Target query. If the query is not a table or a cte, it will be converted into a cte as the merge target.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
MergeWithOutputAsync<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, Expression<Func<string, TTarget, TTarget, TSource, TOutput>>)
Executes merge command and returns output information, affected by merge operations.
public static IAsyncEnumerable<TOutput> MergeWithOutputAsync<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, Expression<Func<string, TTarget, TTarget, TSource, TOutput>> outputExpression)
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputExpression
Expression<Func<string, TTarget, TTarget, TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IAsyncEnumerable<TOutput>
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
- Firebird 3+ (doesn't support more than one record and "action" parameter; database limitation)
MergeWithOutputAsync<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, Expression<Func<string, TTarget, TTarget, TOutput>>)
Executes merge command and returns output information, affected by merge operations.
public static IAsyncEnumerable<TOutput> MergeWithOutputAsync<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, Expression<Func<string, TTarget, TTarget, TOutput>> outputExpression)
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputExpression
Expression<Func<string, TTarget, TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IAsyncEnumerable<TOutput>
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
- Firebird 3+ (doesn't support more than one record and "action" parameter; database limitation)
MergeWithOutputIntoAsync<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, ITable<TOutput>, Expression<Func<string, TTarget, TTarget, TSource, TOutput>>, CancellationToken)
Executes merge command, inserts output information into table and returns total number of target records, affected by merge operations.
public static Task<int> MergeWithOutputIntoAsync<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, ITable<TOutput> outputTable, Expression<Func<string, TTarget, TTarget, TSource, TOutput>> outputExpression, CancellationToken token = default) where TOutput : notnull
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputTable
ITable<TOutput>Table which should handle output result.
outputExpression
Expression<Func<string, TTarget, TTarget, TSource, TOutput>>Output record constructor expression. Optional asynchronous operation cancellation token. Expression supports only record new expression with field initializers.
token
CancellationToken
Returns
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
MergeWithOutputIntoAsync<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, ITable<TOutput>, Expression<Func<string, TTarget, TTarget, TOutput>>, CancellationToken)
Executes merge command, inserts output information into table and returns total number of target records, affected by merge operations.
public static Task<int> MergeWithOutputIntoAsync<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, ITable<TOutput> outputTable, Expression<Func<string, TTarget, TTarget, TOutput>> outputExpression, CancellationToken token = default) where TOutput : notnull
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputTable
ITable<TOutput>Table which should handle output result.
outputExpression
Expression<Func<string, TTarget, TTarget, TOutput>>Output record constructor expression. Optional asynchronous operation cancellation token. Expression supports only record new expression with field initializers.
token
CancellationToken
Returns
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
MergeWithOutputInto<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, ITable<TOutput>, Expression<Func<string, TTarget, TTarget, TSource, TOutput>>)
Executes merge command, inserts output information into table and returns total number of target records, affected by merge operations.
public static int MergeWithOutputInto<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, ITable<TOutput> outputTable, Expression<Func<string, TTarget, TTarget, TSource, TOutput>> outputExpression) where TOutput : notnull
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputTable
ITable<TOutput>Table which should handle output result.
outputExpression
Expression<Func<string, TTarget, TTarget, TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
MergeWithOutputInto<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, ITable<TOutput>, Expression<Func<string, TTarget, TTarget, TOutput>>)
Executes merge command, inserts output information into table and returns total number of target records, affected by merge operations.
public static int MergeWithOutputInto<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, ITable<TOutput> outputTable, Expression<Func<string, TTarget, TTarget, TOutput>> outputExpression) where TOutput : notnull
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputTable
ITable<TOutput>Table which should handle output result.
outputExpression
Expression<Func<string, TTarget, TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
MergeWithOutput<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, Expression<Func<string, TTarget, TTarget, TSource, TOutput>>)
Executes merge command and returns output information, affected by merge operations.
public static IEnumerable<TOutput> MergeWithOutput<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, Expression<Func<string, TTarget, TTarget, TSource, TOutput>> outputExpression)
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputExpression
Expression<Func<string, TTarget, TTarget, TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
- Firebird 3+ (doesn't support more than one record and "action" parameter; database limitation)
MergeWithOutput<TTarget, TSource, TOutput>(IMergeable<TTarget, TSource>, Expression<Func<string, TTarget, TTarget, TOutput>>)
Executes merge command and returns output information, affected by merge operations.
public static IEnumerable<TOutput> MergeWithOutput<TTarget, TSource, TOutput>(this IMergeable<TTarget, TSource> merge, Expression<Func<string, TTarget, TTarget, TOutput>> outputExpression)
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
outputExpression
Expression<Func<string, TTarget, TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2008+
- Firebird 3+ (doesn't support more than one record and "action" parameter; database limitation)
Merge<TTarget>(ITable<TTarget>)
Starts merge operation definition from target table.
public static IMergeableUsing<TTarget> Merge<TTarget>(this ITable<TTarget> target) where TTarget : notnull
Parameters
target
ITable<TTarget>Target table.
Returns
- IMergeableUsing<TTarget>
Returns merge command builder, that contains only target.
Type Parameters
TTarget
Target record type.
Merge<TTarget>(ITable<TTarget>, string)
Starts merge operation definition from target table.
public static IMergeableUsing<TTarget> Merge<TTarget>(this ITable<TTarget> target, string hint) where TTarget : notnull
Parameters
Returns
- IMergeableUsing<TTarget>
Returns merge command builder, that contains only target.
Type Parameters
TTarget
Target record type.
Merge<TTarget>(IQueryable<TTarget>)
Starts merge operation definition from a subquery. If the query is not a table or a cte, it will be converted into a cte as the merge target.
public static IMergeableUsing<TTarget> Merge<TTarget>(this IQueryable<TTarget> target)
Parameters
target
IQueryable<TTarget>Target table.
Returns
- IMergeableUsing<TTarget>
Returns merge command builder, that contains only target.
Type Parameters
TTarget
Target record type.
Merge<TTarget, TSource>(IMergeable<TTarget, TSource>)
Executes merge command and returns total number of target records, affected by merge operations.
public static int Merge<TTarget, TSource>(this IMergeable<TTarget, TSource> merge)
Parameters
merge
IMergeable<TTarget, TSource>Merge command definition.
Returns
- int
Returns number of target table records, affected by merge command.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
OnTargetKey<TTarget>(IMergeableOn<TTarget, TTarget>)
Adds definition of matching of target and source records using primary key columns.
public static IMergeableSource<TTarget, TTarget> OnTargetKey<TTarget>(this IMergeableOn<TTarget, TTarget> merge)
Parameters
merge
IMergeableOn<TTarget, TTarget>Merge command builder.
Returns
- IMergeableSource<TTarget, TTarget>
Returns merge command builder with source, target and match (ON) set.
Type Parameters
TTarget
Target record type.
On<TTarget, TSource>(IMergeableOn<TTarget, TSource>, Expression<Func<TTarget, TSource, bool>>)
Adds definition of matching of target and source records using match condition.
public static IMergeableSource<TTarget, TSource> On<TTarget, TSource>(this IMergeableOn<TTarget, TSource> merge, Expression<Func<TTarget, TSource, bool>> matchCondition)
Parameters
merge
IMergeableOn<TTarget, TSource>Merge command builder.
matchCondition
Expression<Func<TTarget, TSource, bool>>Rule to match/join target and source records.
Returns
- IMergeableSource<TTarget, TSource>
Returns merge command builder with source, target and match (ON) set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
On<TTarget, TSource, TKey>(IMergeableOn<TTarget, TSource>, Expression<Func<TTarget, TKey>>, Expression<Func<TSource, TKey>>)
Adds definition of matching of target and source records using key value.
public static IMergeableSource<TTarget, TSource> On<TTarget, TSource, TKey>(this IMergeableOn<TTarget, TSource> merge, Expression<Func<TTarget, TKey>> targetKey, Expression<Func<TSource, TKey>> sourceKey)
Parameters
merge
IMergeableOn<TTarget, TSource>Merge command builder.
targetKey
Expression<Func<TTarget, TKey>>Target record match key definition.
sourceKey
Expression<Func<TSource, TKey>>Source record match key definition.
Returns
- IMergeableSource<TTarget, TSource>
Returns merge command builder with source, target and match (ON) set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
TKey
Source and target records join/match key type.
Or(TableOptions, TableOptions)
public static TableOptions Or(this TableOptions tableOptions, TableOptions additionalOptions)
Parameters
tableOptions
TableOptionsadditionalOptions
TableOptions
Returns
QueryHint<TSource>(IQueryable<TSource>, string)
Adds a query hint to a generated query.
[Sql.QueryExtension(null, Sql.QueryExtensionScope.QueryHint, typeof(HintExtensionBuilder))]
public static IQueryable<TSource> QueryHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSource
Table record mapping class.
QueryHint<TSource, TParam>(IQueryable<TSource>, string, TParam)
Adds a query hint to the generated query.
[Sql.QueryExtension(null, Sql.QueryExtensionScope.QueryHint, typeof(HintWithParameterExtensionBuilder))]
public static IQueryable<TSource> QueryHint<TSource, TParam>(this IQueryable<TSource> source, string hint, TParam hintParameter) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameter
TParamHint parameter.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSource
Table record mapping class.
TParam
Hint parameter type
QueryHint<TSource, TParam>(IQueryable<TSource>, string, params TParam[])
Adds a query hint to the generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.QueryHint, typeof(HintWithParametersExtensionBuilder), " ")]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.QueryHint, typeof(HintWithParametersExtensionBuilder))]
public static IQueryable<TSource> QueryHint<TSource, TParam>(this IQueryable<TSource> source, string hint, params TParam[] hintParameters) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameters
TParam[]Table hint parameters.
Returns
- IQueryable<TSource>
Table-like query source with hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
QueryName<TSource>(IQueryable<TSource>, string)
Defines query name for specified sub-query. The query cannot be removed during the query optimization.
public static IQueryable<TSource> QueryName<TSource>(this IQueryable<TSource> source, string queryName)
Parameters
source
IQueryable<TSource>Source data query.
queryName
stringQuery name.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSource
Source query record type.
QueryName<TKey, TElement>(IQueryable<IGrouping<TKey, TElement>>, string)
Defines query name for specified sub-query. The query cannot be removed during the query optimization.
public static IQueryable<TKey> QueryName<TKey, TElement>(this IQueryable<IGrouping<TKey, TElement>> grouping, string queryName)
Parameters
grouping
IQueryable<IGrouping<TKey, TElement>>Source data query.
queryName
stringQuery name.
Returns
- IQueryable<TKey>
Query converted into sub-query.
Type Parameters
TKey
The type of the key of the IGrouping<TKey, TElement>.
TElement
The type of the values in the IGrouping<TKey, TElement>.
RemoveOrderBy<TSource>(IQueryable<TSource>)
Removes ordering from current query.
public static IQueryable<TSource> RemoveOrderBy<TSource>(this IQueryable<TSource> source)
Parameters
source
IQueryable<TSource>Source query.
Returns
- IQueryable<TSource>
Unsorted query.
Type Parameters
TSource
Source query record type.
RightJoin<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>)
Defines right outer join between two sub-queries or tables.
public static IQueryable<TSource> RightJoin<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Parameters
source
IQueryable<TSource>Right join operand.
predicate
Expression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSource
Type of record for right join operand.
RightJoin<TOuter, TInner, TResult>(IQueryable<TOuter>, IQueryable<TInner>, Expression<Func<TOuter, TInner, bool>>, Expression<Func<TOuter, TInner, TResult>>)
Defines right outer join between two sub-queries or tables.
public static IQueryable<TResult> RightJoin<TOuter, TInner, TResult>(this IQueryable<TOuter> outer, IQueryable<TInner> inner, Expression<Func<TOuter, TInner, bool>> predicate, Expression<Func<TOuter, TInner, TResult>> resultSelector)
Parameters
outer
IQueryable<TOuter>Left join operand.
inner
IQueryable<TInner>Right join operand.
predicate
Expression<Func<TOuter, TInner, bool>>Join predicate.
resultSelector
Expression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuter
Type of record for left join operand.
TInner
Type of record for right join operand.
TResult
The type of the result elements.
SchemaName<T>(ITable<T>, string?)
Overrides owner/schema name with new name for current query. This call will have effect only for databases that support owner/schema name in fully-qualified table name.
Supported by: DB2, Oracle, PostgreSQL, Informix, SQL Server, Sybase ASE.
public static ITable<T> SchemaName<T>(this ITable<T> table, string? name) where T : notnull
Parameters
Returns
- ITable<T>
Table-like query source with new owner/schema name.
Type Parameters
T
Table record mapping class.
SelectAsync<T>(IDataContext, Expression<Func<T>>)
Loads scalar value or record from database without explicit table source asynchronously. Could be usefull for function calls, querying of database variables or properties, subqueries, execution of code on server side.
public static Task<T> SelectAsync<T>(this IDataContext dataContext, Expression<Func<T>> selector)
Parameters
dataContext
IDataContextDatabase connection context.
selector
Expression<Func<T>>Value selection expression.
Returns
- Task<T>
Requested value.
Type Parameters
T
Type of result.
Select<T>(IDataContext, Expression<Func<T>>)
Loads scalar value or record from database without explicit table source. Could be usefull for function calls, querying of database variables or properties, subqueries, execution of code on server side.
public static T Select<T>(this IDataContext dataContext, Expression<Func<T>> selector)
Parameters
dataContext
IDataContextDatabase connection context.
selector
Expression<Func<T>>Value selection expression.
Returns
- T
Requested value.
Type Parameters
T
Type of result.
ServerName<T>(ITable<T>, string?)
Overrides linked server name with new name for current query. This call will have effect only for databases that support linked server name in fully-qualified table name.
Supported by: SQL Server, Informix, Oracle, SAP HANA2.
public static ITable<T> ServerName<T>(this ITable<T> table, string? name) where T : notnull
Parameters
Returns
- ITable<T>
Table-like query source with new linked server name.
Type Parameters
T
Table record mapping class.
Set<T>(IUpdatable<T>, Expression<Func<T, string>>)
Adds update field expression to query. It can be any expression with string interpolation.
public static IUpdatable<T> Set<T>(this IUpdatable<T> source, Expression<Func<T, string>> setExpression)
Parameters
source
IUpdatable<T>Source query with records to update.
setExpression
Expression<Func<T, string>>Custom update expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
Examples
The following example shows how to append string value to appropriate field.
db.Users.Where(u => u.UserId == id)
.AsUpdatable()
.Set(u => $"{u.Name}" += {str}")
.Update();
Set<T>(IQueryable<T>, Expression<Func<T, string>>)
Adds update field expression to query. It can be any expression with string interpolation.
public static IUpdatable<T> Set<T>(this IQueryable<T> source, Expression<Func<T, string>> setExpression)
Parameters
source
IQueryable<T>Source query with records to update.
setExpression
Expression<Func<T, string>>Custom update expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
Examples
The following example shows how to append string value to appropriate field.
db.Users.Where(u => u.UserId == id)
.Set(u => $"{u.Name}" += {str}")
.Update();
Set<T, TV>(IUpdatable<T>, Expression<Func<T, TV>>, Expression<Func<T, TV>>)
Adds update field expression to query.
public static IUpdatable<T> Set<T, TV>(this IUpdatable<T> source, Expression<Func<T, TV>> extract, Expression<Func<T, TV>> update)
Parameters
source
IUpdatable<T>Source query with records to update.
extract
Expression<Func<T, TV>>Updated field selector expression.
update
Expression<Func<T, TV>>Updated field setter expression. Uses updated record as parameter.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
TV
Updated field type.
Set<T, TV>(IUpdatable<T>, Expression<Func<T, TV>>, Expression<Func<TV>>)
Adds update field expression to query.
public static IUpdatable<T> Set<T, TV>(this IUpdatable<T> source, Expression<Func<T, TV>> extract, Expression<Func<TV>> update)
Parameters
source
IUpdatable<T>Source query with records to update.
extract
Expression<Func<T, TV>>Updated field selector expression.
update
Expression<Func<TV>>Updated field setter expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
TV
Updated field type.
Set<T, TV>(IUpdatable<T>, Expression<Func<T, TV>>, TV)
Adds update field expression to query.
public static IUpdatable<T> Set<T, TV>(this IUpdatable<T> source, Expression<Func<T, TV>> extract, TV value)
Parameters
source
IUpdatable<T>Source query with records to update.
extract
Expression<Func<T, TV>>Updated field selector expression.
value
TVValue, assigned to updated field.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
TV
Updated field type.
Set<T, TV>(IQueryable<T>, Expression<Func<T, TV>>, Expression<Func<T, TV>>)
Adds update field expression to query.
public static IUpdatable<T> Set<T, TV>(this IQueryable<T> source, Expression<Func<T, TV>> extract, Expression<Func<T, TV>> update)
Parameters
source
IQueryable<T>Source query with records to update.
extract
Expression<Func<T, TV>>Updated field selector expression.
update
Expression<Func<T, TV>>Updated field setter expression. Uses updated record as parameter.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
TV
Updated field type.
Set<T, TV>(IQueryable<T>, Expression<Func<T, TV>>, Expression<Func<TV>>)
Adds update field expression to query.
public static IUpdatable<T> Set<T, TV>(this IQueryable<T> source, Expression<Func<T, TV>> extract, Expression<Func<TV>> update)
Parameters
source
IQueryable<T>Source query with records to update.
extract
Expression<Func<T, TV>>Updated field selector expression.
update
Expression<Func<TV>>Updated field setter expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
TV
Updated field type.
Set<T, TV>(IQueryable<T>, Expression<Func<T, TV>>, TV)
Adds update field expression to query.
public static IUpdatable<T> Set<T, TV>(this IQueryable<T> source, Expression<Func<T, TV>> extract, TV value)
Parameters
source
IQueryable<T>Source query with records to update.
extract
Expression<Func<T, TV>>Updated field selector expression.
value
TVValue, assigned to updated field.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
T
Updated record type.
TV
Updated field type.
Skip<TSource>(IQueryable<TSource>, Expression<Func<int>>)
Ignores first N records from source query.
public static IQueryable<TSource> Skip<TSource>(this IQueryable<TSource> source, Expression<Func<int>> count)
Parameters
source
IQueryable<TSource>Source query.
count
Expression<Func<int>>Expression that defines number of records to skip.
Returns
- IQueryable<TSource>
Query without skipped records.
Type Parameters
TSource
Source table record type.
SubQueryHint<TSource>(IQueryable<TSource>, string)
Adds a query hint to a generated query.
[Sql.QueryExtension(null, Sql.QueryExtensionScope.SubQueryHint, typeof(HintExtensionBuilder))]
public static IQueryable<TSource> SubQueryHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSource
Table record mapping class.
SubQueryHint<TSource, TParam>(IQueryable<TSource>, string, TParam)
Adds a query hint to the generated query.
[Sql.QueryExtension(null, Sql.QueryExtensionScope.SubQueryHint, typeof(HintWithParameterExtensionBuilder))]
public static IQueryable<TSource> SubQueryHint<TSource, TParam>(this IQueryable<TSource> source, string hint, TParam hintParameter) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameter
TParamHint parameter.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSource
Table record mapping class.
TParam
Hint parameter type
SubQueryHint<TSource, TParam>(IQueryable<TSource>, string, params TParam[])
Adds a query hint to the generated query.
[Sql.QueryExtension(null, Sql.QueryExtensionScope.SubQueryHint, typeof(HintWithParametersExtensionBuilder))]
public static IQueryable<TSource> SubQueryHint<TSource, TParam>(this IQueryable<TSource> source, string hint, params TParam[] hintParameters) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameters
TParam[]Table hint parameters.
Returns
- IQueryable<TSource>
Table-like query source with hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
TableHint<TSource>(ITable<TSource>, string)
Adds a table hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TableHint, typeof(HintExtensionBuilder))]
public static ITable<TSource> TableHint<TSource>(this ITable<TSource> table, string hint) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSource
Table record mapping class.
TableHint<TSource, TParam>(ITable<TSource>, string, TParam)
Adds a table hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TableHint, typeof(HintWithParameterExtensionBuilder))]
public static ITable<TSource> TableHint<TSource, TParam>(this ITable<TSource> table, string hint, TParam hintParameter) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameter
TParamTable hint parameter.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
TableHint<TSource, TParam>(ITable<TSource>, string, params TParam[])
Adds a table hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder), " ", " ")]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder), " ", ", ")]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TableHint, typeof(HintWithParametersExtensionBuilder))]
public static ITable<TSource> TableHint<TSource, TParam>(this ITable<TSource> table, string hint, params TParam[] hintParameters) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameters
TParam[]Table hint parameters.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
TableID<T>(ITable<T>, string?)
Assigns table id.
public static ITable<T> TableID<T>(this ITable<T> table, string? id) where T : notnull
Parameters
Returns
- ITable<T>
Table-like query source with new name.
Type Parameters
T
Table record mapping class.
TableName<T>(ITable<T>, string)
Overrides table or view name with new name for current query.
public static ITable<T> TableName<T>(this ITable<T> table, string name) where T : notnull
Parameters
Returns
- ITable<T>
Table-like query source with new name.
Type Parameters
T
Table record mapping class.
TablesInScopeHint<TSource>(IQueryable<TSource>, string)
Adds a table hint to all the tables in the method scope.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TablesInScopeHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TablesInScopeHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TablesInScopeHint, typeof(HintExtensionBuilder))]
public static IQueryable<TSource> TablesInScopeHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with table hints.
Type Parameters
TSource
Table record mapping class.
TablesInScopeHint<TSource>(IQueryable<TSource>, string, params object[])
Adds a table hint to all the tables in the method scope.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TablesInScopeHint, typeof(TableSpecHintExtensionBuilder), " ", " ")]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TablesInScopeHint, typeof(TableSpecHintExtensionBuilder), " ", ", ")]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TablesInScopeHint, typeof(HintWithParametersExtensionBuilder))]
public static IQueryable<TSource> TablesInScopeHint<TSource>(this IQueryable<TSource> source, string hint, params object[] hintParameters) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameters
object[]Table hint parameters.
Returns
- IQueryable<TSource>
Query source with table hints.
Type Parameters
TSource
Table record mapping class.
TablesInScopeHint<TSource, TParam>(IQueryable<TSource>, string, TParam)
Adds a table hint to all the tables in the method scope.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TablesInScopeHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TablesInScopeHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TablesInScopeHint, typeof(HintWithParameterExtensionBuilder))]
public static IQueryable<TSource> TablesInScopeHint<TSource, TParam>(this IQueryable<TSource> source, string hint, TParam hintParameter) where TSource : notnull
Parameters
source
IQueryable<TSource>Query source.
hint
stringSQL text, added as a database specific hint to generated query.
hintParameter
TParamTable hint parameter.
Returns
- IQueryable<TSource>
Query source with table hints.
Type Parameters
TSource
Table record mapping class.
TParam
Table hint parameter type.
TagQuery<T>(ITable<T>, string)
Adds a tag comment before generated query for table.
The example below will produce following code before generated query: /* my tag */\r\n
db.Table.TagQuery("my tag");
public static ITable<T> TagQuery<T>(this ITable<T> table, string tagValue) where T : notnull
Parameters
table
ITable<T>Table-like query source.
tagValue
stringTag text to be added as comment before generated query.
Returns
- ITable<T>
Table-like query source with tag.
Type Parameters
T
Table record mapping class.
TagQuery<TSource>(IQueryable<TSource>, string)
Adds a tag comment before generated query.
The example below will produce following code before generated query: /* my tag */\r\n
db.Table.TagQuery("my tag");
public static IQueryable<TSource> TagQuery<TSource>(this IQueryable<TSource> source, string tagValue)
Parameters
source
IQueryable<TSource>Source data query.
tagValue
stringTag text to be added as comment before generated query.
Returns
- IQueryable<TSource>
Query with tag.
Type Parameters
TSource
Table record mapping class.
Take<TSource>(IQueryable<TSource>, int, TakeHints)
Limits number of records, returned from query. Allows to specify TAKE clause hints. Using this method may cause runtime LinqException if take hints are not supported by database.
public static IQueryable<TSource> Take<TSource>(this IQueryable<TSource> source, int count, TakeHints hints)
Parameters
source
IQueryable<TSource>Source query.
count
intSQL TAKE parameter value.
hints
TakeHintsTakeHints hints for SQL TAKE clause.
Returns
- IQueryable<TSource>
Query with limit applied.
Type Parameters
TSource
Source table record type.
Take<TSource>(IQueryable<TSource>, Expression<Func<int>>)
Limits number of records, returned from query.
public static IQueryable<TSource> Take<TSource>(this IQueryable<TSource> source, Expression<Func<int>> count)
Parameters
source
IQueryable<TSource>Source query.
count
Expression<Func<int>>Expression that defines number of records to select.
Returns
- IQueryable<TSource>
Query with limit applied.
Type Parameters
TSource
Source table record type.
Take<TSource>(IQueryable<TSource>, Expression<Func<int>>, TakeHints)
Limits number of records, returned from query. Allows to specify TAKE clause hints. Using this method may cause runtime LinqException if take hints are not supported by database.
public static IQueryable<TSource> Take<TSource>(this IQueryable<TSource> source, Expression<Func<int>> count, TakeHints hints)
Parameters
source
IQueryable<TSource>Source query.
count
Expression<Func<int>>Expression that defines SQL TAKE parameter value.
hints
TakeHintsTakeHints hints for SQL TAKE clause.
Returns
- IQueryable<TSource>
Query with limit applied.
Type Parameters
TSource
Source table record type.
ThenLoad<TEntity, TPreviousProperty, TProperty>(ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>, Expression<Func<TPreviousProperty, IEnumerable<TProperty>>>, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>)
Specifies associations that should be loaded for parent association, loaded by previous LoadWith/ThenLoad call in chain.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
loadFunc
parameter could be used to define additional association loading logic like filters or loading of more associations.
public static ILoadWithQueryable<TEntity, TProperty> ThenLoad<TEntity, TPreviousProperty, TProperty>(this ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>> source, Expression<Func<TPreviousProperty, IEnumerable<TProperty>>> selector, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>> loadFunc) where TEntity : class
Parameters
source
ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>The source query.
selector
Expression<Func<TPreviousProperty, IEnumerable<TProperty>>>A lambda expression representing navigation property to be included (
t => t.Property1
).loadFunc
Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>Defines additional logic for association load query.
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TPreviousProperty
Type of parent association.
TProperty
Type of the related entity to be included.
Examples
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
Following query loads records from Table1 with References1 collection association loaded for each Table1 record with References2 collection association loaded for each record in References1, with filter over References2 record to include only records without "exclude" text in Name property.
db.Table1.LoadWith(r => r.References1).ThenLoad(r1 => r1.References2, r2 => r2.Where(rr2 => !rr2.Name.Contains("exclude")));
ThenLoad<TEntity, TPreviousProperty, TProperty>(ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>, Expression<Func<TPreviousProperty, TProperty?>>)
Specifies associations that should be loaded for parent association, loaded by previous LoadWith/ThenLoad call in chain.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
public static ILoadWithQueryable<TEntity, TProperty> ThenLoad<TEntity, TPreviousProperty, TProperty>(this ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>> source, Expression<Func<TPreviousProperty, TProperty?>> selector) where TEntity : class
Parameters
source
ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>The source query.
selector
Expression<Func<TPreviousProperty, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1
).
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TPreviousProperty
Type of parent association.
TProperty
Type of the related entity to be included.
Examples
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
ThenLoad<TEntity, TPreviousProperty, TProperty>(ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>, Expression<Func<TPreviousProperty, TProperty?>>, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>)
Specifies associations that should be loaded for parent association, loaded by previous LoadWith/ThenLoad call in chain.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
loadFunc
parameter could be used to define additional association loading logic like filters or loading of more associations.
public static ILoadWithQueryable<TEntity, TProperty> ThenLoad<TEntity, TPreviousProperty, TProperty>(this ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>> source, Expression<Func<TPreviousProperty, TProperty?>> selector, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>> loadFunc) where TEntity : class
Parameters
source
ILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>The source query.
selector
Expression<Func<TPreviousProperty, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1
).loadFunc
Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>Defines additional logic for association load query.
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TPreviousProperty
Type of parent association.
TProperty
Type of the related entity to be included.
Examples
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
Following query loads records from Table1 with References1 collection association loaded for each Table1 record with References2 collection association loaded for each record in References1, with filter over References2 record to include only records without "exclude" text in Name property.
db.Table1.LoadWith(r => r.References1).ThenLoad(r1 => r1.References2, r2 => r2.Where(rr2 => !rr2.Name.Contains("exclude")));
ThenLoad<TEntity, TPreviousProperty, TProperty>(ILoadWithQueryable<TEntity, TPreviousProperty>, Expression<Func<TPreviousProperty, IEnumerable<TProperty>?>>, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>)
Specifies associations that should be loaded for parent association, loaded by previous LoadWith/ThenLoad call in chain.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
loadFunc
parameter could be used to define additional association loading logic like filters or loading of more associations.
public static ILoadWithQueryable<TEntity, TProperty> ThenLoad<TEntity, TPreviousProperty, TProperty>(this ILoadWithQueryable<TEntity, TPreviousProperty> source, Expression<Func<TPreviousProperty, IEnumerable<TProperty>?>> selector, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>> loadFunc) where TEntity : class
Parameters
source
ILoadWithQueryable<TEntity, TPreviousProperty>The source query.
selector
Expression<Func<TPreviousProperty, IEnumerable<TProperty>>>A lambda expression representing navigation property to be included (
t => t.Property1
).loadFunc
Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>Defines additional logic for association load query.
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TPreviousProperty
Type of parent association.
TProperty
Type of the related entity to be included.
Examples
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
Following query loads records from Table1 with References1 collection association loaded for each Table1 record with References2 collection association loaded for each record in References1, with filter over References2 record to include only records without "exclude" text in Name property.
db.Table1.LoadWith(r => r.References1).ThenLoad(r1 => r1.References2, r2 => r2.Where(rr2 => !rr2.Name.Contains("exclude")));
ThenLoad<TEntity, TPreviousProperty, TProperty>(ILoadWithQueryable<TEntity, TPreviousProperty>, Expression<Func<TPreviousProperty, TProperty?>>)
Specifies associations that should be loaded for parent association, loaded by previous LoadWith/ThenLoad call in chain.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
public static ILoadWithQueryable<TEntity, TProperty> ThenLoad<TEntity, TPreviousProperty, TProperty>(this ILoadWithQueryable<TEntity, TPreviousProperty> source, Expression<Func<TPreviousProperty, TProperty?>> selector) where TEntity : class
Parameters
source
ILoadWithQueryable<TEntity, TPreviousProperty>The source query.
selector
Expression<Func<TPreviousProperty, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1
).
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TPreviousProperty
Type of parent association.
TProperty
Type of the related entity to be included.
Examples
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
ThenLoad<TEntity, TPreviousProperty, TProperty>(ILoadWithQueryable<TEntity, TPreviousProperty>, Expression<Func<TPreviousProperty, TProperty?>>, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>)
Specifies associations that should be loaded for parent association, loaded by previous LoadWith/ThenLoad call in chain.
All associations, specified in selector
expression, will be loaded.
Take into account that use of this method could require multiple queries to load all requested associations.
loadFunc
parameter could be used to define additional association loading logic like filters or loading of more associations.
public static ILoadWithQueryable<TEntity, TProperty> ThenLoad<TEntity, TPreviousProperty, TProperty>(this ILoadWithQueryable<TEntity, TPreviousProperty> source, Expression<Func<TPreviousProperty, TProperty?>> selector, Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>> loadFunc) where TEntity : class
Parameters
source
ILoadWithQueryable<TEntity, TPreviousProperty>The source query.
selector
Expression<Func<TPreviousProperty, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1
).loadFunc
Expression<Func<IQueryable<TProperty>, IQueryable<TProperty>>>Defines additional logic for association load query.
Returns
- ILoadWithQueryable<TEntity, TProperty>
Returns new query with related data included.
Type Parameters
TEntity
Type of entity being queried.
TPreviousProperty
Type of parent association.
TProperty
Type of the related entity to be included.
Examples
Following queries loads records from Table1 with Reference1 association and then loads records from Reference2 association for each loaded Reference1 record.
db.Table1.LoadWith(r => r.Reference1.Reference2);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.Reference1).ThenLoad(r => r.Reference2);
Note that a way you access collection association record (by index, using First() method) doesn't affect query results and always select all records.
db.Table1.LoadWith(r => r.References1[0].References2.First().Reference3);
Same query using ThenLoad extension.
db.Table1.LoadWith(r => r.References1).ThenLoad(r => r.References2).ThenLoad(r => r.Reference3);
Following query loads records from Table1 with References1 collection association loaded for each Table1 record with References2 collection association loaded for each record in References1, with filter over References2 record to include only records without "exclude" text in Name property.
db.Table1.LoadWith(r => r.References1).ThenLoad(r1 => r1.References2, r2 => r2.Where(rr2 => !rr2.Name.Contains("exclude")));
ThenOrByDescending<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>)
Adds descending sort expression to a query. If query already sorted, existing sorting will be preserved and updated with new sort.
public static IOrderedQueryable<TSource> ThenOrByDescending<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
Parameters
source
IQueryable<TSource>Source query.
keySelector
Expression<Func<TSource, TKey>>Sort expression selector.
Returns
- IOrderedQueryable<TSource>
Sorted query.
Type Parameters
TSource
Source query record type.
TKey
Sort expression type.
ThenOrBy<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>)
Adds ascending sort expression to a query. If query already sorted, existing sorting will be preserved and updated with new sort.
public static IOrderedQueryable<TSource> ThenOrBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
Parameters
source
IQueryable<TSource>Source query.
keySelector
Expression<Func<TSource, TKey>>Sort expression selector.
Returns
- IOrderedQueryable<TSource>
Sorted query.
Type Parameters
TSource
Source query record type.
TKey
Sort expression type.
TruncateAsync<T>(ITable<T>, bool, CancellationToken)
Truncates database table asynchronously.
public static Task<int> TruncateAsync<T>(this ITable<T> target, bool resetIdentity = true, CancellationToken token = default) where T : notnull
Parameters
target
ITable<T>Truncated table.
resetIdentity
boolPerforms reset identity column.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Table record type.
Truncate<T>(ITable<T>, bool)
Truncates database table.
public static int Truncate<T>(this ITable<T> target, bool resetIdentity = true) where T : notnull
Parameters
Returns
- int
Number of affected records. Usually
-1
as it is not data modification operation.
Type Parameters
T
Table record type.
UnionAll<TSource>(IQueryable<TSource>, IEnumerable<TSource>)
Concatenates two sequences, similar to Concat<TSource>(IQueryable<TSource>, IEnumerable<TSource>).
public static IQueryable<TSource> UnionAll<TSource>(this IQueryable<TSource> source1, IEnumerable<TSource> source2)
Parameters
source1
IQueryable<TSource>The first sequence to concatenate.
source2
IEnumerable<TSource>The sequence to concatenate to the first sequence.
Returns
- IQueryable<TSource>
An IQueryable<T> that contains the concatenated elements of the two input sequences.
Type Parameters
TSource
The type of the elements of the input sequences.
Exceptions
- ArgumentNullException
source1
orsource2
is null.
UpdateAsync<T>(IUpdatable<T>, CancellationToken)
Executes update operation asynchronously for already configured update query.
public static Task<int> UpdateAsync<T>(this IUpdatable<T> source, CancellationToken token = default)
Parameters
source
IUpdatable<T>Update query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
UpdateAsync<T>(IQueryable<T>, Expression<Func<T, bool>>, Expression<Func<T, T>>, CancellationToken)
Executes update operation asynchronously using source query as record filter with additional filter expression.
public static Task<int> UpdateAsync<T>(this IQueryable<T> source, Expression<Func<T, bool>> predicate, Expression<Func<T, T>> setter, CancellationToken token = default)
Parameters
source
IQueryable<T>Source data query.
predicate
Expression<Func<T, bool>>Filter expression, to specify what records from source query should be updated.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
UpdateAsync<T>(IQueryable<T>, Expression<Func<T, T>>, CancellationToken)
Executes update operation asynchronously using source query as record filter.
public static Task<int> UpdateAsync<T>(this IQueryable<T> source, Expression<Func<T, T>> setter, CancellationToken token = default)
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
UpdateAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Executes update-from-source operation asynchronously against target table.
public static Task<int> UpdateAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
UpdateAsync<TSource, TTarget>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, CancellationToken)
Executes update-from-source operation asynchronously against target table. Also see UpdateAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken) method.
public static Task<int> UpdateAsync<TSource, TTarget>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table selection expression.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
UpdateWhenMatchedAndThenDelete<TTarget>(IMergeableSource<TTarget, TTarget>, Expression<Func<TTarget, TTarget, bool>>, Expression<Func<TTarget, TTarget, bool>>)
IMPORTANT: This operation supported only by Oracle Database. Adds new update with delete operation to merge and returns new merge command with added operation. This operation updates record in target table using data from the same fields of source record for each record that was matched in source and target and passes filtering with specified predicate, if it wasn't processed by previous operations. After that it removes updated records if they are matched by delete predicate.
public static IMergeable<TTarget, TTarget> UpdateWhenMatchedAndThenDelete<TTarget>(this IMergeableSource<TTarget, TTarget> merge, Expression<Func<TTarget, TTarget, bool>> searchCondition, Expression<Func<TTarget, TTarget, bool>> deleteCondition)
Parameters
merge
IMergeableSource<TTarget, TTarget>Merge command builder interface.
searchCondition
Expression<Func<TTarget, TTarget, bool>>Update execution condition over target and source records.
deleteCondition
Expression<Func<TTarget, TTarget, bool>>Delete execution condition over updated target and source records.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target and source records type.
UpdateWhenMatchedAndThenDelete<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, TSource, bool>>, Expression<Func<TTarget, TSource, TTarget>>, Expression<Func<TTarget, TSource, bool>>)
IMPORTANT: This operation supported only by Oracle Database. Adds new update with delete operation to merge and returns new merge command with added operation. This operation updates record in target table using user-defined values for target columns for each record that was matched in source and target and passes filtering with specified predicate, if it wasn't processed by previous operations. After that it removes updated records if they matched by delete predicate.
public static IMergeable<TTarget, TSource> UpdateWhenMatchedAndThenDelete<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, TSource, bool>> searchCondition, Expression<Func<TTarget, TSource, TTarget>> setter, Expression<Func<TTarget, TSource, bool>> deleteCondition)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
searchCondition
Expression<Func<TTarget, TSource, bool>>Update execution condition over target and source records.
setter
Expression<Func<TTarget, TSource, TTarget>>Update record expression using target and source records. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
deleteCondition
Expression<Func<TTarget, TSource, bool>>Delete execution condition over updated target and source records.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
UpdateWhenMatchedAnd<TTarget>(IMergeableSource<TTarget, TTarget>, Expression<Func<TTarget, TTarget, bool>>)
Adds new update operation to merge and returns new merge command with added operation. This operation updates record in target table using data from the same fields of source record for each record that was matched in source and target and passes filtering with specified predicate, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TTarget> UpdateWhenMatchedAnd<TTarget>(this IMergeableSource<TTarget, TTarget> merge, Expression<Func<TTarget, TTarget, bool>> searchCondition)
Parameters
merge
IMergeableSource<TTarget, TTarget>Merge command builder interface.
searchCondition
Expression<Func<TTarget, TTarget, bool>>Operation execution condition over target and source records.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target and source records type.
UpdateWhenMatchedAnd<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, TSource, bool>>, Expression<Func<TTarget, TSource, TTarget>>)
Adds new update operation to merge and returns new merge command with added operation. This operation updates record in target table using user-defined values for target columns for each record that was matched in source and target and passes filtering with specified predicate, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> UpdateWhenMatchedAnd<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, TSource, bool>> searchCondition, Expression<Func<TTarget, TSource, TTarget>> setter)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
searchCondition
Expression<Func<TTarget, TSource, bool>>Operation execution condition over target and source records.
setter
Expression<Func<TTarget, TSource, TTarget>>Update record expression using target and source records. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
UpdateWhenMatchedThenDelete<TTarget>(IMergeableSource<TTarget, TTarget>, Expression<Func<TTarget, TTarget, bool>>)
IMPORTANT: This operation supported only by Oracle Database. Adds new update with delete operation to merge and returns new merge command with added operation. This operation updates record in target table using data from the same fields of source record for each record that was matched in source and target, if it wasn't processed by previous operations. After that it removes updated records if they are matched by delete predicate.
public static IMergeable<TTarget, TTarget> UpdateWhenMatchedThenDelete<TTarget>(this IMergeableSource<TTarget, TTarget> merge, Expression<Func<TTarget, TTarget, bool>> deleteCondition)
Parameters
merge
IMergeableSource<TTarget, TTarget>Merge command builder interface.
deleteCondition
Expression<Func<TTarget, TTarget, bool>>Delete execution condition over updated target and source records.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target and source records type.
UpdateWhenMatchedThenDelete<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, TSource, TTarget>>, Expression<Func<TTarget, TSource, bool>>)
IMPORTANT: This operation supported only by Oracle Database. Adds new update with delete operation to merge and returns new merge command with added operation. This operation updates record in target table using user-defined values for target columns for each record that was matched in source and target, if it wasn't processed by previous operations. After that it removes updated records if they matched by delete predicate.
public static IMergeable<TTarget, TSource> UpdateWhenMatchedThenDelete<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, TSource, TTarget>> setter, Expression<Func<TTarget, TSource, bool>> deleteCondition)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
setter
Expression<Func<TTarget, TSource, TTarget>>Update record expression using target and source records. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
deleteCondition
Expression<Func<TTarget, TSource, bool>>Delete execution condition over updated target and source records.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
UpdateWhenMatched<TTarget>(IMergeableSource<TTarget, TTarget>)
Adds new update operation to merge and returns new merge command with added operation. This operation updates record in target table using data from the same fields of source record for each record that was matched in source and target, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TTarget> UpdateWhenMatched<TTarget>(this IMergeableSource<TTarget, TTarget> merge)
Parameters
merge
IMergeableSource<TTarget, TTarget>Merge command builder interface.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target and source records type.
UpdateWhenMatched<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, TSource, TTarget>>)
Adds new update operation to merge and returns new merge command with added operation. This operation updates record in target table using user-defined values for target columns for each record that was matched in source and target, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> UpdateWhenMatched<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, TSource, TTarget>> setter)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
setter
Expression<Func<TTarget, TSource, TTarget>>Update record expression using target and source records. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
UpdateWhenNotMatchedBySourceAnd<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, bool>>, Expression<Func<TTarget, TTarget>>)
IMPORTANT: This operation supported only by Microsoft SQL Server. Adds new update by source operation to merge and returns new merge command with added operation. This operation updates record in target table for each record that was matched only in target using user-defined values for target columns, if it passed filtering by operation predicate and wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> UpdateWhenNotMatchedBySourceAnd<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, bool>> searchCondition, Expression<Func<TTarget, TTarget>> setter)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
searchCondition
Expression<Func<TTarget, bool>>Operation execution condition over target record.
setter
Expression<Func<TTarget, TTarget>>Update record expression using target record. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
UpdateWhenNotMatchedBySource<TTarget, TSource>(IMergeableSource<TTarget, TSource>, Expression<Func<TTarget, TTarget>>)
IMPORTANT: This operation supported only by Microsoft SQL Server. Adds new update by source operation to merge and returns new merge command with added operation. This operation updates record in target table for each record that was matched only in target using user-defined values for target columns, if it wasn't processed by previous operations.
public static IMergeable<TTarget, TSource> UpdateWhenNotMatchedBySource<TTarget, TSource>(this IMergeableSource<TTarget, TSource> merge, Expression<Func<TTarget, TTarget>> setter)
Parameters
merge
IMergeableSource<TTarget, TSource>Merge command builder interface.
setter
Expression<Func<TTarget, TTarget>>Update record expression using target record. Expression should be a call to target record constructor with field/properties initializers to be recognized by API.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
UpdateWithOutputAsync<T>(IUpdatable<T>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<UpdateOutput<T>[]> UpdateWithOutputAsync<T>(this IUpdatable<T> source, CancellationToken token = default)
Parameters
source
IUpdatable<T>Source data query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<T>[]>
Deleted and inserted values for every record updated.
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutputAsync<T>(IQueryable<T>, Expression<Func<T, T>>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<UpdateOutput<T>[]> UpdateWithOutputAsync<T>(this IQueryable<T> source, Expression<Func<T, T>> setter, CancellationToken token = default)
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<T>[]>
Deleted and inserted values for every record updated.
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutputAsync<T, TOutput>(IUpdatable<T>, Expression<Func<T, T, TOutput>>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<TOutput[]> UpdateWithOutputAsync<T, TOutput>(this IUpdatable<T> source, Expression<Func<T, T, TOutput>> outputExpression, CancellationToken token = default)
Parameters
source
IUpdatable<T>Source data query.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutputAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<UpdateOutput<TTarget>[]> UpdateWithOutputAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<TTarget>[]>
Deleted and inserted values for every record updated.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutputAsync<T, TOutput>(IQueryable<T>, Expression<Func<T, T>>, Expression<Func<T, T, TOutput>>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<TOutput[]> UpdateWithOutputAsync<T, TOutput>(this IQueryable<T> source, Expression<Func<T, T>> setter, Expression<Func<T, T, TOutput>> outputExpression, CancellationToken token = default)
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutputAsync<TSource, TTarget>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<UpdateOutput<TTarget>[]> UpdateWithOutputAsync<TSource, TTarget>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<TTarget>[]>
Deleted and inserted values for every record updated.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutputAsync<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget, TTarget, TOutput>>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<TOutput[]> UpdateWithOutputAsync<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression, CancellationToken token = default) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutputAsync<TSource, TTarget, TOutput>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget, TTarget, TOutput>>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<TOutput[]> UpdateWithOutputAsync<TSource, TTarget, TOutput>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutputIntoAsync<T>(IUpdatable<T>, ITable<T>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<int> UpdateWithOutputIntoAsync<T>(this IUpdatable<T> source, ITable<T> outputTable, CancellationToken token = default) where T : class
Parameters
source
IUpdatable<T>Source data query.
outputTable
ITable<T>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<T>(IQueryable<T>, Expression<Func<T, T>>, ITable<T>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<int> UpdateWithOutputIntoAsync<T>(this IQueryable<T> source, Expression<Func<T, T>> setter, ITable<T> outputTable, CancellationToken token = default) where T : class
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<T>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<T, TOutput>(IUpdatable<T>, ITable<TOutput>, Expression<Func<T, T, TOutput>>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<int> UpdateWithOutputIntoAsync<T, TOutput>(this IUpdatable<T> source, ITable<TOutput> outputTable, Expression<Func<T, T, TOutput>> outputExpression, CancellationToken token = default) where TOutput : class
Parameters
source
IUpdatable<T>Source data query.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TTarget>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<int> UpdateWithOutputIntoAsync<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TTarget> outputTable, CancellationToken token = default) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<T, TOutput>(IQueryable<T>, Expression<Func<T, T>>, ITable<TOutput>, Expression<Func<T, T, TOutput>>, CancellationToken)
Executes update operation using source query as record filter.
public static Task<int> UpdateWithOutputIntoAsync<T, TOutput>(this IQueryable<T> source, Expression<Func<T, T>> setter, ITable<TOutput> outputTable, Expression<Func<T, T, TOutput>> outputExpression, CancellationToken token = default) where TOutput : class
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<TSource, TTarget>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, ITable<TTarget>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<int> UpdateWithOutputIntoAsync<TSource, TTarget>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, ITable<TTarget> outputTable, CancellationToken token = default) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TOutput>, Expression<Func<TSource, TTarget, TTarget, TOutput>>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<int> UpdateWithOutputIntoAsync<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression, CancellationToken token = default) where TTarget : class where TOutput : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputIntoAsync<TSource, TTarget, TOutput>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, ITable<TOutput>, Expression<Func<TSource, TTarget, TTarget, TOutput>>, CancellationToken)
Executes update-from-source operation against target table.
public static Task<int> UpdateWithOutputIntoAsync<TSource, TTarget, TOutput>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression, CancellationToken token = default) where TOutput : class
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<T>(IUpdatable<T>, ITable<T>)
Executes update operation using source query as record filter.
public static int UpdateWithOutputInto<T>(this IUpdatable<T> source, ITable<T> outputTable) where T : class
Parameters
source
IUpdatable<T>Source data query.
outputTable
ITable<T>Output table.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<T>(IQueryable<T>, Expression<Func<T, T>>, ITable<T>)
Executes update operation using source query as record filter.
public static int UpdateWithOutputInto<T>(this IQueryable<T> source, Expression<Func<T, T>> setter, ITable<T> outputTable) where T : class
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<T>Output table.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<T, TOutput>(IUpdatable<T>, ITable<TOutput>, Expression<Func<T, T, TOutput>>)
Executes update operation using source query as record filter.
public static int UpdateWithOutputInto<T, TOutput>(this IUpdatable<T> source, ITable<TOutput> outputTable, Expression<Func<T, T, TOutput>> outputExpression) where TOutput : class
Parameters
source
IUpdatable<T>Source data query.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TTarget>)
Executes update-from-source operation against target table.
public static int UpdateWithOutputInto<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TTarget> outputTable) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<T, TOutput>(IQueryable<T>, Expression<Func<T, T>>, ITable<TOutput>, Expression<Func<T, T, TOutput>>)
Executes update operation using source query as record filter.
public static int UpdateWithOutputInto<T, TOutput>(this IQueryable<T> source, Expression<Func<T, T>> setter, ITable<TOutput> outputTable, Expression<Func<T, T, TOutput>> outputExpression) where TOutput : class
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<TSource, TTarget>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, ITable<TTarget>)
Executes update-from-source operation against target table.
public static int UpdateWithOutputInto<TSource, TTarget>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, ITable<TTarget> outputTable) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, ITable<TOutput>, Expression<Func<TSource, TTarget, TTarget, TOutput>>)
Executes update-from-source operation against target table.
public static int UpdateWithOutputInto<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression) where TTarget : class where TOutput : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.
Returns
- int
Output values from the update statement.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutputInto<TSource, TTarget, TOutput>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, ITable<TOutput>, Expression<Func<TSource, TTarget, TTarget, TOutput>>)
Executes update-from-source operation against target table.
public static int UpdateWithOutputInto<TSource, TTarget, TOutput>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, ITable<TOutput> outputTable, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression) where TOutput : class
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTable
ITable<TOutput>Output table.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.
Returns
- int
Output values from the update statement.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
UpdateWithOutput<T>(IUpdatable<T>)
Executes update operation using source query as record filter.
public static IEnumerable<UpdateOutput<T>> UpdateWithOutput<T>(this IUpdatable<T> source)
Parameters
source
IUpdatable<T>Source data query.
Returns
- IEnumerable<UpdateOutput<T>>
Deleted and inserted values for every record updated.
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutput<T>(IQueryable<T>, Expression<Func<T, T>>)
Executes update operation using source query as record filter.
public static IEnumerable<UpdateOutput<T>> UpdateWithOutput<T>(this IQueryable<T> source, Expression<Func<T, T>> setter)
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
Returns
- IEnumerable<UpdateOutput<T>>
Deleted and inserted values for every record updated.
Type Parameters
T
Updated table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutput<T, TOutput>(IUpdatable<T>, Expression<Func<T, T, TOutput>>)
Executes update operation using source query as record filter.
public static IEnumerable<TOutput> UpdateWithOutput<T, TOutput>(this IUpdatable<T> source, Expression<Func<T, T, TOutput>> outputExpression)
Parameters
source
IUpdatable<T>Source data query.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializer.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutput<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Executes update-from-source operation against target table.
public static IEnumerable<UpdateOutput<TTarget>> UpdateWithOutput<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
Returns
- IEnumerable<UpdateOutput<TTarget>>
Deleted and inserted values for every record updated.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutput<T, TOutput>(IQueryable<T>, Expression<Func<T, T>>, Expression<Func<T, T, TOutput>>)
Executes update operation using source query as record filter.
public static IEnumerable<TOutput> UpdateWithOutput<T, TOutput>(this IQueryable<T> source, Expression<Func<T, T>> setter, Expression<Func<T, T, TOutput>> outputExpression)
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
T
deleted,T
inserted). Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
T
Updated table record type.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutput<TSource, TTarget>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>)
Executes update-from-source operation against target table.
public static IEnumerable<UpdateOutput<TTarget>> UpdateWithOutput<TSource, TTarget>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter)
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
Returns
- IEnumerable<UpdateOutput<TTarget>>
Deleted and inserted values for every record updated.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
UpdateWithOutput<TSource, TTarget, TOutput>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget, TTarget, TOutput>>)
Executes update-from-source operation against target table.
public static IEnumerable<TOutput> UpdateWithOutput<TSource, TTarget, TOutput>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression) where TTarget : class
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
UpdateWithOutput<TSource, TTarget, TOutput>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget, TTarget, TOutput>>)
Executes update-from-source operation against target table.
public static IEnumerable<TOutput> UpdateWithOutput<TSource, TTarget, TOutput>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter, Expression<Func<TSource, TTarget, TTarget, TOutput>> outputExpression)
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpression
Expression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSource
source,TTarget
deleted,TTarget
inserted). Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
TOutput
Output table record type.
Remarks
Database support:
- SQL Server 2005+
- Firebird 2.5+ (doesn't support more than one record; database limitation)
- PostgreSQL (doesn't support old data; database limitation)
- SQLite 3.35+ (doesn't support old data; database limitation)
Update<T>(IUpdatable<T>)
Executes update operation for already configured update query.
public static int Update<T>(this IUpdatable<T> source)
Parameters
source
IUpdatable<T>Update query.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
Update<T>(IQueryable<T>, Expression<Func<T, bool>>, Expression<Func<T, T>>)
Executes update operation using source query as record filter with additional filter expression.
public static int Update<T>(this IQueryable<T> source, Expression<Func<T, bool>> predicate, Expression<Func<T, T>> setter)
Parameters
source
IQueryable<T>Source data query.
predicate
Expression<Func<T, bool>>Filter expression, to specify what records from source query should be updated.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
Update<T>(IQueryable<T>, Expression<Func<T, T>>)
Executes update operation using source query as record filter.
public static int Update<T>(this IQueryable<T> source, Expression<Func<T, T>> setter)
Parameters
source
IQueryable<T>Source data query.
setter
Expression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
T
Updated table record type.
Update<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>)
Executes update-from-source operation against target table.
public static int Update<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) where TTarget : notnull
Parameters
source
IQueryable<TSource>Source data query.
target
ITable<TTarget>Target table.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
Update<TSource, TTarget>(IQueryable<TSource>, Expression<Func<TSource, TTarget>>, Expression<Func<TSource, TTarget>>)
Executes update-from-source operation against target table. Also see Update<TSource, TTarget>(IQueryable<TSource>, ITable<TTarget>, Expression<Func<TSource, TTarget>>) method.
public static int Update<TSource, TTarget>(this IQueryable<TSource> source, Expression<Func<TSource, TTarget>> target, Expression<Func<TSource, TTarget>> setter)
Parameters
source
IQueryable<TSource>Source data query.
target
Expression<Func<TSource, TTarget>>Target table selection expression.
setter
Expression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
TSource
Source query record type.
TTarget
Target table mapping class.
UsingTarget<TTarget>(IMergeableUsing<TTarget>)
Sets target table as merge command source.
public static IMergeableOn<TTarget, TTarget> UsingTarget<TTarget>(this IMergeableUsing<TTarget> merge)
Parameters
merge
IMergeableUsing<TTarget>Merge command builder.
Returns
- IMergeableOn<TTarget, TTarget>
Returns merge command builder with source and target set.
Type Parameters
TTarget
Target record type.
Using<TTarget, TSource>(IMergeableUsing<TTarget>, IEnumerable<TSource>)
Adds source collection to merge command definition.
public static IMergeableOn<TTarget, TSource> Using<TTarget, TSource>(this IMergeableUsing<TTarget> merge, IEnumerable<TSource> source)
Parameters
merge
IMergeableUsing<TTarget>Merge command builder.
source
IEnumerable<TSource>Source data collection.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
Using<TTarget, TSource>(IMergeableUsing<TTarget>, IQueryable<TSource>)
Adds source query to merge command definition.
public static IMergeableOn<TTarget, TSource> Using<TTarget, TSource>(this IMergeableUsing<TTarget> merge, IQueryable<TSource> source)
Parameters
merge
IMergeableUsing<TTarget>Merge command builder.
source
IQueryable<TSource>Source data query.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTarget
Target record type.
TSource
Source record type.
Value<T, TV>(ITable<T>, Expression<Func<T, TV>>, Expression<Func<TV>>)
Starts insert operation LINQ query definition from field setter expression.
public static IValueInsertable<T> Value<T, TV>(this ITable<T> source, Expression<Func<T, TV>> field, Expression<Func<TV>> value) where T : notnull
Parameters
source
ITable<T>Source table to insert to.
field
Expression<Func<T, TV>>Setter field selector expression.
value
Expression<Func<TV>>Setter field value expression.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
T
Target table record type.
TV
Setter field type.
Value<T, TV>(ITable<T>, Expression<Func<T, TV>>, TV)
Starts insert operation LINQ query definition from field setter expression.
public static IValueInsertable<T> Value<T, TV>(this ITable<T> source, Expression<Func<T, TV>> field, TV value) where T : notnull
Parameters
source
ITable<T>Source table to insert to.
field
Expression<Func<T, TV>>Setter field selector expression.
value
TVSetter field value.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
T
Target table record type.
TV
Setter field type.
Value<T, TV>(IValueInsertable<T>, Expression<Func<T, TV>>, Expression<Func<TV>>)
Add field setter to insert operation LINQ query.
public static IValueInsertable<T> Value<T, TV>(this IValueInsertable<T> source, Expression<Func<T, TV>> field, Expression<Func<TV>> value)
Parameters
source
IValueInsertable<T>Insert query.
field
Expression<Func<T, TV>>Setter field selector expression.
value
Expression<Func<TV>>Setter field value expression.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
T
Target table record type.
TV
Setter field type.
Value<T, TV>(IValueInsertable<T>, Expression<Func<T, TV>>, TV)
Add field setter to insert operation LINQ query.
public static IValueInsertable<T> Value<T, TV>(this IValueInsertable<T> source, Expression<Func<T, TV>> field, TV value)
Parameters
source
IValueInsertable<T>Insert query.
field
Expression<Func<T, TV>>Setter field selector expression.
value
TVSetter field value.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
T
Target table record type.
TV
Setter field type.
Value<TSource, TTarget, TValue>(ISelectInsertable<TSource, TTarget>, Expression<Func<TTarget, TValue>>, Expression<Func<TSource, TValue>>)
Add field setter to insert operation LINQ query.
public static ISelectInsertable<TSource, TTarget> Value<TSource, TTarget, TValue>(this ISelectInsertable<TSource, TTarget> source, Expression<Func<TTarget, TValue>> field, Expression<Func<TSource, TValue>> value)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
field
Expression<Func<TTarget, TValue>>Setter field selector expression.
value
Expression<Func<TSource, TValue>>Setter field value expression. Accepts source record as parameter.
Returns
- ISelectInsertable<TSource, TTarget>
Insert query.
Type Parameters
TSource
Source record type.
TTarget
Target record type
TValue
Field type.
Value<TSource, TTarget, TValue>(ISelectInsertable<TSource, TTarget>, Expression<Func<TTarget, TValue>>, Expression<Func<TValue>>)
Add field setter to insert operation LINQ query.
public static ISelectInsertable<TSource, TTarget> Value<TSource, TTarget, TValue>(this ISelectInsertable<TSource, TTarget> source, Expression<Func<TTarget, TValue>> field, Expression<Func<TValue>> value)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
field
Expression<Func<TTarget, TValue>>Setter field selector expression.
value
Expression<Func<TValue>>Setter field value expression.
Returns
- ISelectInsertable<TSource, TTarget>
Insert query.
Type Parameters
TSource
Source record type.
TTarget
Target record type
TValue
Field type.
Value<TSource, TTarget, TValue>(ISelectInsertable<TSource, TTarget>, Expression<Func<TTarget, TValue>>, TValue)
Add field setter to insert operation LINQ query.
public static ISelectInsertable<TSource, TTarget> Value<TSource, TTarget, TValue>(this ISelectInsertable<TSource, TTarget> source, Expression<Func<TTarget, TValue>> field, TValue value)
Parameters
source
ISelectInsertable<TSource, TTarget>Insert query.
field
Expression<Func<TTarget, TValue>>Setter field selector expression.
value
TValueSetter field value.
Returns
- ISelectInsertable<TSource, TTarget>
Insert query.
Type Parameters
TSource
Source record type.
TTarget
Target record type
TValue
Field type.
WithTableExpression<T>(ITable<T>, string)
Replaces access to a table in generated query with SQL expression. Example below adds hint to a table. Also see With<TSource>(ITable<TSource>, string) method.
var tableWithHint = db.Table.WithTableExpression("{0} {1} with (UpdLock)");
public static ITable<T> WithTableExpression<T>(this ITable<T> table, string expression) where T : notnull
Parameters
table
ITable<T>Table-like query source.
expression
stringSQL template to use instead of table name. Template supports two parameters:
- {0} original table name;
- {1} table alias.
Returns
- ITable<T>
Table-like query source with new table source expression.
Type Parameters
T
Table record mapping class.
With<TSource>(ITable<TSource>, string)
Adds a table hint to a table in generated query.
[Sql.QueryExtension("Oracle", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension("MySql", Sql.QueryExtensionScope.TableHint, typeof(TableSpecHintExtensionBuilder))]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.TableHint, typeof(HintExtensionBuilder))]
public static ITable<TSource> With<TSource>(this ITable<TSource> table, string hint) where TSource : notnull
Parameters
table
ITable<TSource>Table-like query source.
hint
stringSQL text, added as a database specific hint to generated query.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSource
Table record mapping class.