Class LinqExtensions
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
Contains extension methods for LINQ queries.
public static class LinqExtensions
- Inheritance
-
LinqExtensions
- Inherited Members
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
sourceIQueryable<TSource>Source query.
Returns
- IQueryable<TSource>
Common table expression.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query.
namestringCommon table expression name.
Returns
- IQueryable<TSource>
Common table expression.
Type Parameters
TSourceSource 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
sourceIEnumerable<TElement>A sequence to convert.
dataContextIDataContextDatabase connection context.
Returns
- IQueryable<TElement>
An IQueryable<T> that represents the input sequence.
Type Parameters
TElementThe type of the elements of
source.
Exceptions
- ArgumentNullException
sourceis 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
sourceIQueryable<TSource>Source data query.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source data query.
queryNamestringQuery name.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSourceSource 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
groupingIQueryable<IGrouping<TKey, TElement>>Source data query.
Returns
- IQueryable<TKey>
Query converted into sub-query.
Type Parameters
TKeyThe type of the key of the IGrouping<TKey, TElement>.
TElementThe 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
groupingIQueryable<IGrouping<TKey, TElement>>Source data query.
queryNamestringQuery name.
Returns
- IQueryable<TKey>
Query converted into sub-query.
Type Parameters
TKeyThe type of the key of the IGrouping<TKey, TElement>.
TElementThe 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
sourceIQueryable<T>Source IQueryable<T> query.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TQuery 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
sourceITable<T>Target table.
Returns
- IValueInsertable<T>
Insertable source query.
Type Parameters
TTarget 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
outerIQueryable<TOuter>Left join operand.
innerIQueryable<TInner>Right join operand.
resultSelectorExpression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuterType of record for left join operand.
TInnerType of record for right join operand.
TResultThe 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
TTable 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
sourceIQueryable<T>Query that returns records to delete.
predicateExpression<Func<T, bool>>Filter expression, to specify what records from source should be deleted.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
sourceIQueryable<T>Query that returns records to delete.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TMapping 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
searchConditionExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
searchConditionExpression<Func<TTarget, bool>>Operation execution condition over target record.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
Returns
- IMergeable<TTarget, TSource>
Returns new merge command builder with new operation.
Type Parameters
TTargetTarget record type.
TSourceSource 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TSource[]>
Array of records.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
outputExpressionExpression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Array of records.
Type Parameters
TSourceSource query record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
outputTableITable<TOutput>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
outputTableITable<TOutput>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
Returns
- IEnumerable<TSource>
Enumeration of records.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query, that returns data for delete operation.
outputExpressionExpression<Func<TSource, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Enumeration of records.
Type Parameters
TSourceSource query record type.
TOutputOutput 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
sourceIQueryable<T>Query that returns records to delete.
Returns
- int
Number of deleted records.
Type Parameters
TMapping 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
sourceIQueryable<T>Query that returns records to delete.
predicateExpression<Func<T, bool>>Filter expression, to specify what records from source should be deleted.
Returns
- int
Number of deleted records.
Type Parameters
TMapping 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
groupingIQueryable<IGrouping<TKey, TElement>>Source data query.
Returns
- IQueryable<IGrouping<TKey, TElement>>
Query with suppressed grouping guard.
Type Parameters
TKeyThe type of the key of the IGrouping<TKey, TElement>.
TElementThe 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
targetITable<T>Dropped table.
throwExceptionIfNotExistsboolIf
false, any exception during drop operation will be silently catched and0returned. This behavior is not correct and will be fixed in future to mask only missing table exceptions. Tracked by issue. Default value:true.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
targetITable<T>Dropped table.
throwExceptionIfNotExistsboolIf
false, any exception during drop operation will be silently catched and0returned. 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
-1as it is not data modification operation.
Type Parameters
TTable 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
sourceIQueryable<TSource>Source query.
indexExpression<Func<int>>Expression that defines index of record to select.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TSource>
Record at specified position.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query.
indexExpression<Func<int>>Expression that defines index of record to select.
tokenCancellationTokenOptional 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
TSourceSource 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
sourceIQueryable<TSource>Source query.
indexExpression<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
TSourceSource 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
sourceIQueryable<TSource>Source query.
indexExpression<Func<int>>Expression that defines index of record to select.
Returns
- TSource
Record at specified position.
Type Parameters
TSourceSource 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
source1IQueryable<TSource>An IQueryable<T> whose elements that are not also in
source2will be returned.source2IEnumerable<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
TSourceThe type of the elements of the input sequences.
Exceptions
- ArgumentNullException
source1orsource2is 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
sourceIQueryable<TSource>Right join operand.
predicateExpression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSourceType 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
outerIQueryable<TOuter>Left join operand.
innerIQueryable<TInner>Right join operand.
predicateExpression<Func<TOuter, TInner, bool>>Join predicate.
resultSelectorExpression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuterType of record for left join operand.
TInnerType of record for right join operand.
TResultThe 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
queryIQueryable<T>Query to test.
mangleNamesboolShould 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
tableOptionsTableOptions
Returns
HasDropIfExists(TableOptions)
public static bool HasDropIfExists(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
HasIsGlobalTemporaryData(TableOptions)
public static bool HasIsGlobalTemporaryData(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
HasIsGlobalTemporaryStructure(TableOptions)
public static bool HasIsGlobalTemporaryStructure(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
HasIsLocalTemporaryData(TableOptions)
public static bool HasIsLocalTemporaryData(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
HasIsLocalTemporaryStructure(TableOptions)
public static bool HasIsLocalTemporaryStructure(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
HasIsTemporary(TableOptions)
public static bool HasIsTemporary(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
HasIsTransactionTemporaryData(TableOptions)
public static bool HasIsTransactionTemporaryData(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
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
sourceIQueryable<TSource>Source data query.
keySelectorExpression<Func<TSource, TKey>>A function to specify which fields are unique.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSourceSource query record type.
TKeyKey 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
sourceIQueryable<TSource>Source query to filter.
predicateExpression<Func<TSource, bool>>Filtering expression.
Returns
- IQueryable<TSource>
Filtered query.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query.
entityTypesType[]Optional types with which filters should be disabled.
Returns
- IQueryable<TSource>
Query with disabled filters.
Type Parameters
TSourceSource query record type.
IndexHint<TSource>(ITable<TSource>, string)
Adds an index hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- ITable<TSource>
Table-like query source with index hints.
Type Parameters
TSourceTable record mapping class.
IndexHint<TSource, TParam>(ITable<TSource>, string, TParam)
Adds an index hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParameterTParamTable hint parameter.
Returns
- ITable<TSource>
Table-like query source with index hints.
Type Parameters
TSourceTable record mapping class.
TParamTable hint parameter type.
IndexHint<TSource, TParam>(ITable<TSource>, string, params TParam[])
Adds an index hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParametersTParam[]Table hint parameters.
Returns
- ITable<TSource>
Table-like query source with index hints.
Type Parameters
TSourceTable record mapping class.
TParamTable 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
sourceIQueryable<TSource>Source data query.
Returns
- IQueryable<TSource>
Query with inlined parameters.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Right join operand.
predicateExpression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSourceType 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
outerIQueryable<TOuter>Left join operand.
innerIQueryable<TInner>Right join operand.
predicateExpression<Func<TOuter, TInner, bool>>Join predicate.
resultSelectorExpression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuterType of record for left join operand.
TInnerType of record for right join operand.
TResultThe 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
insertSetterExpression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetterExpression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
keySelectorExpression<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.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
targetITable<T>Target table.
insertSetterExpression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetterExpression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
targetITable<T>Target table.
insertSetterExpression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetterExpression<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
TTable 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
targetITable<T>Target table.
insertSetterExpression<Func<T>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
onDuplicateKeyUpdateSetterExpression<Func<T, T>>Updated record constructor expression. Expression supports only target table record new expression with field initializers. Accepts updated record as parameter.
keySelectorExpression<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
TTable 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
mergeIMergeableSource<TTarget, TTarget>Merge command builder interface.
searchConditionExpression<Func<TTarget, bool>>Operation execution condition over source record.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTargetTarget 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
searchConditionExpression<Func<TSource, bool>>Operation execution condition over source record.
setterExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TTarget>Merge command builder interface.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTargetTarget 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
setterExpression<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
TTargetTarget record type.
TSourceSource 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- decimal
Inserted record's identity value.
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
Returns
- decimal?
Inserted record's identity value.
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
Returns
- decimal?
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- object
Inserted record's identity value.
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
Returns
- object
Inserted record's identity value.
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
Returns
- object
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- int
Inserted record's identity value.
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
Returns
- int?
Inserted record's identity value.
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
Returns
- int?
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- long
Inserted record's identity value.
Type Parameters
TInserted 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
sourceIValueInsertable<T>Insert query.
Returns
- long?
Inserted record's identity value.
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
Returns
- long?
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget>
Inserted record.
Type Parameters
TTargetInserted 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
targetITable<TTarget>Target table.
objTTargetObject with data to insert.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget>
Inserted record.
Type Parameters
TTargetInserted 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
sourceIValueInsertable<T>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<T>
Inserted record.
Type Parameters
TTarget 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput>
Inserted record.
Type Parameters
TTargetInserted record type.
TOutputOutput 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
sourceISelectInsertable<TSource, TTarget>Insert query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget>
Inserted record.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIValueInsertable<T>Insert query.
outputExpressionExpression<Func<T, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput>
Inserted record.
Type Parameters
TTarget table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TTarget[]>
Array of records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Array of records.
Type Parameters
TSourceSource query record type.
TTargetTarget table record type.
TOutputOutput 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTargetInserted 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTargetInserted record type.
TOutputOutput 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
sourceISelectInsertable<TSource, TTarget>Insert query.
outputTableITable<TTarget>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget table record type.
TOutputOutput 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TTargetInserted 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TTargetInserted record type.
TOutputOutput 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
sourceISelectInsertable<TSource, TTarget>Insert query.
outputTableITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget table record type.
TOutputOutput 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- TTarget
Inserted record.
Type Parameters
TTargetInserted 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
targetITable<TTarget>Target table.
objTTargetObject with data to insert.
Returns
- TTarget
Inserted record.
Type Parameters
TTargetInserted 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
sourceIValueInsertable<T>Insert query.
Returns
- T
Inserted record.
Type Parameters
TTarget 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
targetITable<TTarget>Target table.
setterExpression<Func<TTarget>>Insert expression. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- TOutput
Inserted record.
Type Parameters
TTargetInserted record type.
TOutputOutput 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
sourceISelectInsertable<TSource, TTarget>Insert query.
Returns
- TTarget
Inserted record.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIValueInsertable<T>Insert query.
outputExpressionExpression<Func<T, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- TOutput
Inserted record.
Type Parameters
TTarget table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Inserted record constructor expression. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TTarget, TOutput>>Output record constructor expression. Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Enumeration of records.
Type Parameters
TSourceSource query record type.
TTargetTarget table record type.
TOutputOutput 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
targetITable<T>Target table.
setterExpression<Func<T>>Insert expression. Expression supports only target table record new expression with field initializers.
Returns
- int
Number of affected records.
Type Parameters
TInserted record type.
Insert<T>(IValueInsertable<T>)
Executes insert query.
public static int Insert<T>(this IValueInsertable<T> source)
Parameters
sourceIValueInsertable<T>Insert query.
Returns
- int
Number of affected records.
Type Parameters
TTarget 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
sourceISelectInsertable<TSource, TTarget>Insert query.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source query, that returns data for insert operation.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
source1IQueryable<TSource>A sequence whose elements that also appear in
source2are returned.source2IEnumerable<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
TSourceThe type of the elements of the input sequences.
Exceptions
- ArgumentNullException
source1orsource2is 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
dataContextIDataContextDatabase connection context.
targetITable<T>Target table.
Returns
- IValueInsertable<T>
Insertable source query.
Type Parameters
TTarget 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
Returns
- ISelectInsertable<TSource, TTarget>
Insertable source query.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
IsSet(TableOptions)
public static bool IsSet(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
IsTemporaryOptionSet(TableOptions)
public static bool IsTemporaryOptionSet(this TableOptions tableOptions)
Parameters
tableOptionsTableOptions
Returns
JoinHint<TSource>(IQueryable<TSource>, string)
Adds a join hint to a generated query.
[IsQueryable]
[Sql.QueryExtension(Sql.QueryExtensionScope.JoinHint, typeof(NoneExtensionBuilder))]
public static IQueryable<TSource> JoinHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with join hints.
Type Parameters
TSourceTable 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
sourceIQueryable<TSource>Right join operand.
joinTypeSqlJoinTypeType of join.
predicateExpression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSourceType 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
outerIQueryable<TOuter>Left join operand.
innerIQueryable<TInner>Right join operand.
joinTypeSqlJoinTypeType of join.
predicateExpression<Func<TOuter, TInner, bool>>Join predicate.
resultSelectorExpression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuterType of record for left join operand.
TInnerType of record for right join operand.
TResultThe 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
sourceIQueryable<TSource>Right join operand.
predicateExpression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSourceType 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
outerIQueryable<TOuter>Left join operand.
innerIQueryable<TInner>Right join operand.
predicateExpression<Func<TOuter, TInner, bool>>Join predicate.
resultSelectorExpression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuterType of record for left join operand.
TInnerType of record for right join operand.
TResultThe 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
tableITable<T>Table-like query source.
selectorExpression<Func<T, object>>Association selection expression.
Returns
- ITable<T>
Table-like query source.
Type Parameters
TTable 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
sourceIQueryable<TEntity>The source query.
selectorExpression<Func<TEntity, IEnumerable<TProperty>>>A lambda expression representing navigation property to be included (
t => t.Property1).loadFuncExpression<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
TEntityType of entity being queried.
TPropertyType 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
sourceIQueryable<TEntity>The source query.
selectorExpression<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
TEntityType of entity being queried.
TPropertyType 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
sourceIQueryable<TEntity>The source query.
selectorExpression<Func<TEntity, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1).loadFuncExpression<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
TEntityType of entity being queried.
TPropertyType 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
mergeIMergeable<TTarget, TSource>Merge command definition.
tokenCancellationTokenAsynchronous operation cancellation token.
Returns
Type Parameters
TTargetTarget record type.
TSourceSource 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTargetTarget record type.
TSourceSource 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
hintstringDatabase-specific merge hint.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTargetTarget record type.
TSourceSource 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
sourceIQueryable<TSource>Source data query.
targetIQueryable<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputExpressionExpression<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
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputExpressionExpression<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
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputTableITable<TOutput>Table which should handle output result.
outputExpressionExpression<Func<string, TTarget, TTarget, TSource, TOutput>>Output record constructor expression. Optional asynchronous operation cancellation token. Expression supports only record new expression with field initializers.
tokenCancellationToken
Returns
Type Parameters
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputTableITable<TOutput>Table which should handle output result.
outputExpressionExpression<Func<string, TTarget, TTarget, TOutput>>Output record constructor expression. Optional asynchronous operation cancellation token. Expression supports only record new expression with field initializers.
tokenCancellationToken
Returns
Type Parameters
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputTableITable<TOutput>Table which should handle output result.
outputExpressionExpression<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
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputTableITable<TOutput>Table which should handle output result.
outputExpressionExpression<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
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputExpressionExpression<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
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
mergeIMergeable<TTarget, TSource>Merge command definition.
outputExpressionExpression<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
TTargetTarget record type.
TSourceSource record type.
TOutputOutput 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
targetITable<TTarget>Target table.
Returns
- IMergeableUsing<TTarget>
Returns merge command builder, that contains only target.
Type Parameters
TTargetTarget 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
TTargetTarget 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
targetIQueryable<TTarget>Target table.
Returns
- IMergeableUsing<TTarget>
Returns merge command builder, that contains only target.
Type Parameters
TTargetTarget 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
mergeIMergeable<TTarget, TSource>Merge command definition.
Returns
- int
Returns number of target table records, affected by merge command.
Type Parameters
TTargetTarget record type.
TSourceSource 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
mergeIMergeableOn<TTarget, TTarget>Merge command builder.
Returns
- IMergeableSource<TTarget, TTarget>
Returns merge command builder with source, target and match (ON) set.
Type Parameters
TTargetTarget 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
mergeIMergeableOn<TTarget, TSource>Merge command builder.
matchConditionExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableOn<TTarget, TSource>Merge command builder.
targetKeyExpression<Func<TTarget, TKey>>Target record match key definition.
sourceKeyExpression<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
TTargetTarget record type.
TSourceSource record type.
TKeySource and target records join/match key type.
Or(TableOptions, TableOptions)
public static TableOptions Or(this TableOptions tableOptions, TableOptions additionalOptions)
Parameters
tableOptionsTableOptionsadditionalOptionsTableOptions
Returns
QueryHint<TSource>(IQueryable<TSource>, string)
Adds a query hint to a generated query.
[IsQueryable]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.QueryHint, typeof(HintExtensionBuilder))]
public static IQueryable<TSource> QueryHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSourceTable record mapping class.
QueryHint<TSource, TParam>(IQueryable<TSource>, string, TParam)
Adds a query hint to the generated query.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParameterTParamHint parameter.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSourceTable record mapping class.
TParamHint parameter type
QueryHint<TSource, TParam>(IQueryable<TSource>, string, params TParam[])
Adds a query hint to the generated query.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParametersTParam[]Table hint parameters.
Returns
- IQueryable<TSource>
Table-like query source with hints.
Type Parameters
TSourceTable record mapping class.
TParamTable 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
sourceIQueryable<TSource>Source data query.
queryNamestringQuery name.
Returns
- IQueryable<TSource>
Query converted into sub-query.
Type Parameters
TSourceSource 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
groupingIQueryable<IGrouping<TKey, TElement>>Source data query.
queryNamestringQuery name.
Returns
- IQueryable<TKey>
Query converted into sub-query.
Type Parameters
TKeyThe type of the key of the IGrouping<TKey, TElement>.
TElementThe 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
sourceIQueryable<TSource>Source query.
Returns
- IQueryable<TSource>
Unsorted query.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Right join operand.
predicateExpression<Func<TSource, bool>>Join predicate.
Returns
- IQueryable<TSource>
Right operand.
Type Parameters
TSourceType 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
outerIQueryable<TOuter>Left join operand.
innerIQueryable<TInner>Right join operand.
predicateExpression<Func<TOuter, TInner, bool>>Join predicate.
resultSelectorExpression<Func<TOuter, TInner, TResult>>A function to create a result element from two matching elements.
Returns
- IQueryable<TResult>
Right operand.
Type Parameters
TOuterType of record for left join operand.
TInnerType of record for right join operand.
TResultThe 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
TTable 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
dataContextIDataContextDatabase connection context.
selectorExpression<Func<T>>Value selection expression.
Returns
- Task<T>
Requested value.
Type Parameters
TType 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
dataContextIDataContextDatabase connection context.
selectorExpression<Func<T>>Value selection expression.
Returns
- T
Requested value.
Type Parameters
TType 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
TTable 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
sourceIUpdatable<T>Source query with records to update.
setExpressionExpression<Func<T, string>>Custom update expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated 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
sourceIQueryable<T>Source query with records to update.
setExpressionExpression<Func<T, string>>Custom update expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated 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
sourceIUpdatable<T>Source query with records to update.
extractExpression<Func<T, TV>>Updated field selector expression.
updateExpression<Func<T, TV>>Updated field setter expression. Uses updated record as parameter.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated record type.
TVUpdated 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
sourceIUpdatable<T>Source query with records to update.
extractExpression<Func<T, TV>>Updated field selector expression.
updateExpression<Func<TV>>Updated field setter expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated record type.
TVUpdated 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
sourceIUpdatable<T>Source query with records to update.
extractExpression<Func<T, TV>>Updated field selector expression.
valueTVValue, assigned to updated field.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated record type.
TVUpdated 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
sourceIQueryable<T>Source query with records to update.
extractExpression<Func<T, TV>>Updated field selector expression.
updateExpression<Func<T, TV>>Updated field setter expression. Uses updated record as parameter.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated record type.
TVUpdated 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
sourceIQueryable<T>Source query with records to update.
extractExpression<Func<T, TV>>Updated field selector expression.
updateExpression<Func<TV>>Updated field setter expression.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated record type.
TVUpdated 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
sourceIQueryable<T>Source query with records to update.
extractExpression<Func<T, TV>>Updated field selector expression.
valueTVValue, assigned to updated field.
Returns
- IUpdatable<T>
IUpdatable<T> query.
Type Parameters
TUpdated record type.
TVUpdated 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
sourceIQueryable<TSource>Source query.
countExpression<Func<int>>Expression that defines number of records to skip.
Returns
- IQueryable<TSource>
Query without skipped records.
Type Parameters
TSourceSource table record type.
SubQueryHint<TSource>(IQueryable<TSource>, string)
Adds a query hint to a generated query.
[IsQueryable]
[Sql.QueryExtension(null, Sql.QueryExtensionScope.SubQueryHint, typeof(HintExtensionBuilder))]
public static IQueryable<TSource> SubQueryHint<TSource>(this IQueryable<TSource> source, string hint) where TSource : notnull
Parameters
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSourceTable record mapping class.
SubQueryHint<TSource, TParam>(IQueryable<TSource>, string, TParam)
Adds a query hint to the generated query.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParameterTParamHint parameter.
Returns
- IQueryable<TSource>
Query source with hints.
Type Parameters
TSourceTable record mapping class.
TParamHint parameter type
SubQueryHint<TSource, TParam>(IQueryable<TSource>, string, params TParam[])
Adds a query hint to the generated query.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParametersTParam[]Table hint parameters.
Returns
- IQueryable<TSource>
Table-like query source with hints.
Type Parameters
TSourceTable record mapping class.
TParamTable hint parameter type.
TableHint<TSource>(ITable<TSource>, string)
Adds a table hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSourceTable record mapping class.
TableHint<TSource, TParam>(ITable<TSource>, string, TParam)
Adds a table hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParameterTParamTable hint parameter.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSourceTable record mapping class.
TParamTable hint parameter type.
TableHint<TSource, TParam>(ITable<TSource>, string, params TParam[])
Adds a table hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParametersTParam[]Table hint parameters.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSourceTable record mapping class.
TParamTable 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
TTable 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
TTable record mapping class.
TablesInScopeHint<TSource>(IQueryable<TSource>, string)
Adds a table hint to all the tables in the method scope.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- IQueryable<TSource>
Query source with table hints.
Type Parameters
TSourceTable record mapping class.
TablesInScopeHint<TSource>(IQueryable<TSource>, string, params object[])
Adds a table hint to all the tables in the method scope.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParametersobject[]Table hint parameters.
Returns
- IQueryable<TSource>
Query source with table hints.
Type Parameters
TSourceTable record mapping class.
TablesInScopeHint<TSource, TParam>(IQueryable<TSource>, string, TParam)
Adds a table hint to all the tables in the method scope.
[IsQueryable]
[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
sourceIQueryable<TSource>Query source.
hintstringSQL text, added as a database specific hint to generated query.
hintParameterTParamTable hint parameter.
Returns
- IQueryable<TSource>
Query source with table hints.
Type Parameters
TSourceTable record mapping class.
TParamTable 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
tableITable<T>Table-like query source.
tagValuestringTag text to be added as comment before generated query.
Returns
- ITable<T>
Table-like query source with tag.
Type Parameters
TTable 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
sourceIQueryable<TSource>Source data query.
tagValuestringTag text to be added as comment before generated query.
Returns
- IQueryable<TSource>
Query with tag.
Type Parameters
TSourceTable 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
sourceIQueryable<TSource>Source query.
countintSQL TAKE parameter value.
hintsTakeHintsTakeHints hints for SQL TAKE clause.
Returns
- IQueryable<TSource>
Query with limit applied.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query.
countExpression<Func<int>>Expression that defines number of records to select.
Returns
- IQueryable<TSource>
Query with limit applied.
Type Parameters
TSourceSource 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
sourceIQueryable<TSource>Source query.
countExpression<Func<int>>Expression that defines SQL TAKE parameter value.
hintsTakeHintsTakeHints hints for SQL TAKE clause.
Returns
- IQueryable<TSource>
Query with limit applied.
Type Parameters
TSourceSource 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
sourceILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>The source query.
selectorExpression<Func<TPreviousProperty, IEnumerable<TProperty>>>A lambda expression representing navigation property to be included (
t => t.Property1).loadFuncExpression<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
TEntityType of entity being queried.
TPreviousPropertyType of parent association.
TPropertyType 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
sourceILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>The source query.
selectorExpression<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
TEntityType of entity being queried.
TPreviousPropertyType of parent association.
TPropertyType 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
sourceILoadWithQueryable<TEntity, IEnumerable<TPreviousProperty>>The source query.
selectorExpression<Func<TPreviousProperty, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1).loadFuncExpression<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
TEntityType of entity being queried.
TPreviousPropertyType of parent association.
TPropertyType 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
sourceILoadWithQueryable<TEntity, TPreviousProperty>The source query.
selectorExpression<Func<TPreviousProperty, IEnumerable<TProperty>>>A lambda expression representing navigation property to be included (
t => t.Property1).loadFuncExpression<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
TEntityType of entity being queried.
TPreviousPropertyType of parent association.
TPropertyType 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
sourceILoadWithQueryable<TEntity, TPreviousProperty>The source query.
selectorExpression<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
TEntityType of entity being queried.
TPreviousPropertyType of parent association.
TPropertyType 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
sourceILoadWithQueryable<TEntity, TPreviousProperty>The source query.
selectorExpression<Func<TPreviousProperty, TProperty>>A lambda expression representing navigation property to be included (
t => t.Property1).loadFuncExpression<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
TEntityType of entity being queried.
TPreviousPropertyType of parent association.
TPropertyType 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
sourceIQueryable<TSource>Source query.
keySelectorExpression<Func<TSource, TKey>>Sort expression selector.
Returns
- IOrderedQueryable<TSource>
Sorted query.
Type Parameters
TSourceSource query record type.
TKeySort 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
sourceIQueryable<TSource>Source query.
keySelectorExpression<Func<TSource, TKey>>Sort expression selector.
Returns
- IOrderedQueryable<TSource>
Sorted query.
Type Parameters
TSourceSource query record type.
TKeySort 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
targetITable<T>Truncated table.
resetIdentityboolPerforms reset identity column.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTable 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
-1as it is not data modification operation.
Type Parameters
TTable 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
source1IQueryable<TSource>The first sequence to concatenate.
source2IEnumerable<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
TSourceThe type of the elements of the input sequences.
Exceptions
- ArgumentNullException
source1orsource2is 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
sourceIUpdatable<T>Update query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
predicateExpression<Func<T, bool>>Filter expression, to specify what records from source query should be updated.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table selection expression.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
mergeIMergeableSource<TTarget, TTarget>Merge command builder interface.
searchConditionExpression<Func<TTarget, TTarget, bool>>Update execution condition over target and source records.
deleteConditionExpression<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
TTargetTarget 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
searchConditionExpression<Func<TTarget, TSource, bool>>Update execution condition over target and source records.
setterExpression<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.
deleteConditionExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TTarget>Merge command builder interface.
searchConditionExpression<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
TTargetTarget 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
searchConditionExpression<Func<TTarget, TSource, bool>>Operation execution condition over target and source records.
setterExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TTarget>Merge command builder interface.
deleteConditionExpression<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
TTargetTarget 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
setterExpression<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.
deleteConditionExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TTarget>Merge command builder interface.
Returns
- IMergeable<TTarget, TTarget>
Returns new merge command builder with new operation.
Type Parameters
TTargetTarget 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
setterExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
searchConditionExpression<Func<TTarget, bool>>Operation execution condition over target record.
setterExpression<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
TTargetTarget record type.
TSourceSource 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
mergeIMergeableSource<TTarget, TSource>Merge command builder interface.
setterExpression<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
TTargetTarget record type.
TSourceSource 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
sourceIUpdatable<T>Source data query.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<T>[]>
Deleted and inserted values for every record updated.
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<T>[]>
Deleted and inserted values for every record updated.
Type Parameters
TUpdated 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
sourceIUpdatable<T>Source data query.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<TTarget>[]>
Deleted and inserted values for every record updated.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<UpdateOutput<TTarget>[]>
Deleted and inserted values for every record updated.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TOutput[]>
Output values from the update statement.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIUpdatable<T>Source data query.
outputTableITable<T>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<T>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated 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
sourceIUpdatable<T>Source data query.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.tokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIUpdatable<T>Source data query.
outputTableITable<T>Output table.
Returns
- int
Number of updated records.
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<T>Output table.
Returns
- int
Number of updated records.
Type Parameters
TUpdated 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
sourceIUpdatable<T>Source data query.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.
Returns
- int
Number of updated records.
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TTarget>Output table.
Returns
- int
Number of affected records.
Type Parameters
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.
Returns
- int
Output values from the update statement.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputTableITable<TOutput>Output table.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.
Returns
- int
Output values from the update statement.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIUpdatable<T>Source data query.
Returns
- IEnumerable<UpdateOutput<T>>
Deleted and inserted values for every record updated.
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
setterExpression<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
TUpdated 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
sourceIUpdatable<T>Source data query.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializer.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<T>Source data query.
setterExpression<Func<T, T>>Update expression. Uses updated record as parameter. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<T, T, TOutput>>Output record constructor expression. Parameters passed are as follows: (
Tdeleted,Tinserted). Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
TUpdated table record type.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table.
setterExpression<Func<TSource, TTarget>>Update expression. Uses record from source query as parameter. Expression supports only target table record new expression with field initializers.
outputExpressionExpression<Func<TSource, TTarget, TTarget, TOutput>>Output record constructor expression. Parameters passed are as follows: (
TSourcesource,TTargetdeleted,TTargetinserted). Expression supports only record new expression with field initializers.
Returns
- IEnumerable<TOutput>
Output values from the update statement.
Type Parameters
TSourceSource query record type.
TTargetTarget table mapping class.
TOutputOutput 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
sourceIUpdatable<T>Update query.
Returns
- int
Number of updated records.
Type Parameters
TUpdated 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
sourceIQueryable<T>Source data query.
predicateExpression<Func<T, bool>>Filter expression, to specify what records from source query should be updated.
setterExpression<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
TUpdated 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
sourceIQueryable<T>Source data query.
setterExpression<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
TUpdated 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
sourceIQueryable<TSource>Source data query.
targetITable<TTarget>Target table.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
sourceIQueryable<TSource>Source data query.
targetExpression<Func<TSource, TTarget>>Target table selection expression.
setterExpression<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
TSourceSource query record type.
TTargetTarget 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
mergeIMergeableUsing<TTarget>Merge command builder.
Returns
- IMergeableOn<TTarget, TTarget>
Returns merge command builder with source and target set.
Type Parameters
TTargetTarget 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
mergeIMergeableUsing<TTarget>Merge command builder.
sourceIEnumerable<TSource>Source data collection.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTargetTarget record type.
TSourceSource 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
mergeIMergeableUsing<TTarget>Merge command builder.
sourceIQueryable<TSource>Source data query.
Returns
- IMergeableOn<TTarget, TSource>
Returns merge command builder with source and target set.
Type Parameters
TTargetTarget record type.
TSourceSource 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
sourceITable<T>Source table to insert to.
fieldExpression<Func<T, TV>>Setter field selector expression.
valueExpression<Func<TV>>Setter field value expression.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
TTarget table record type.
TVSetter 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
sourceITable<T>Source table to insert to.
fieldExpression<Func<T, TV>>Setter field selector expression.
valueTVSetter field value.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
TTarget table record type.
TVSetter 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
sourceIValueInsertable<T>Insert query.
fieldExpression<Func<T, TV>>Setter field selector expression.
valueExpression<Func<TV>>Setter field value expression.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
TTarget table record type.
TVSetter 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
sourceIValueInsertable<T>Insert query.
fieldExpression<Func<T, TV>>Setter field selector expression.
valueTVSetter field value.
Returns
- IValueInsertable<T>
Insert query.
Type Parameters
TTarget table record type.
TVSetter 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
sourceISelectInsertable<TSource, TTarget>Insert query.
fieldExpression<Func<TTarget, TValue>>Setter field selector expression.
valueExpression<Func<TSource, TValue>>Setter field value expression. Accepts source record as parameter.
Returns
- ISelectInsertable<TSource, TTarget>
Insert query.
Type Parameters
TSourceSource record type.
TTargetTarget record type
TValueField 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
sourceISelectInsertable<TSource, TTarget>Insert query.
fieldExpression<Func<TTarget, TValue>>Setter field selector expression.
valueExpression<Func<TValue>>Setter field value expression.
Returns
- ISelectInsertable<TSource, TTarget>
Insert query.
Type Parameters
TSourceSource record type.
TTargetTarget record type
TValueField 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
sourceISelectInsertable<TSource, TTarget>Insert query.
fieldExpression<Func<TTarget, TValue>>Setter field selector expression.
valueTValueSetter field value.
Returns
- ISelectInsertable<TSource, TTarget>
Insert query.
Type Parameters
TSourceSource record type.
TTargetTarget record type
TValueField 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
tableITable<T>Table-like query source.
expressionstringSQL 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
TTable record mapping class.
With<TSource>(ITable<TSource>, string)
Adds a table hint to a table in generated query.
[IsQueryable]
[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
tableITable<TSource>Table-like query source.
hintstringSQL text, added as a database specific hint to generated query.
Returns
- ITable<TSource>
Table-like query source with table hints.
Type Parameters
TSourceTable record mapping class.