Table of Contents

Class DataExtensions

Namespace
LinqToDB.Tools
Assembly
linq2db.dll
public static class DataExtensions
Inheritance
DataExtensions
Inherited Members

Methods

RetrieveIdentityAsync<T>(IEnumerable<T>, IDataContext, bool, bool, CancellationToken)

Initializes source columns, marked with IsIdentity or IdentityAttribute with identity values:

  • if column had sequence name set using SequenceNameAttribute and useSequenceName set to true, values from sequence used. Implemented for: Oracle, PostgreSQL
  • if table has identity configured and useIdentity set to true, values from sequence used. Implemented for: SQL Server 2005+
  • Otherwise column initialized with values, incremented by 1 starting with max value from database for this column plus 1.
public static Task<IEnumerable<T>> RetrieveIdentityAsync<T>(this IEnumerable<T> source, IDataContext context, bool useSequenceName = true, bool useIdentity = false, CancellationToken cancellationToken = default) where T : notnull

Parameters

source IEnumerable<T>

Ordered list of entities to initialize.

context IDataContext

Data connection to use to retrieve sequence values of max used value for column.

useSequenceName bool

Enables identity values retrieval from sequence for columns with sequence name specified in mapping using SequenceNameAttribute. Implemented for Oracle and PostgreSQL.

useIdentity bool

Enables identity values retrieval from table with identity column. Implemented for SQL Server 2005+.

cancellationToken CancellationToken

Asynchronous operation cancellation token.

Returns

Task<IEnumerable<T>>

Returns new collection of identity fields initialized or source if entity had no identity columns.

Type Parameters

T

Entity type.

RetrieveIdentity<T>(IEnumerable<T>, IDataContext, bool, bool)

Initializes source columns, marked with IsIdentity or IdentityAttribute with identity values:

  • if column had sequence name set using SequenceNameAttribute and useSequenceName set to true, values from sequence used. Implemented for: Oracle, PostgreSQL
  • if table has identity configured and useIdentity set to true, values from sequence used. Implemented for: SQL Server 2005+
  • Otherwise column initialized with values, incremented by 1 starting with max value from database for this column plus 1.
public static IEnumerable<T> RetrieveIdentity<T>(this IEnumerable<T> source, IDataContext context, bool useSequenceName = true, bool useIdentity = false) where T : notnull

Parameters

source IEnumerable<T>

Ordered list of entities to initialize.

context IDataContext

Data connection to use to retrieve sequence values of max used value for column.

useSequenceName bool

Enables identity values retrieval from sequence for columns with sequence name specified in mapping using SequenceNameAttribute. Implemented for Oracle and PostgreSQL.

useIdentity bool

Enables identity values retrieval from table with identity column. Implemented for SQL Server 2005+.

Returns

IEnumerable<T>

Returns new collection of identity fields initialized or source if entity had no identity columns.

Type Parameters

T

Entity type.