Table of Contents

Class DataExtensions

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

Methods

RetrieveIdentity<T>(IEnumerable<T>, DataConnection, 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, DataConnection context, bool useSequenceName = true, bool useIdentity = false) where T : notnull

Parameters

source IEnumerable<T>

Ordered list of entities to initialize.

context DataConnection

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.