Show / Hide Table of Contents

    Class IdGeneratorBase

    Base class for simple creation of implementations of IIdGenerator.

    Inheritance
    System.Object
    IdGeneratorBase
    SqlServerIdGenerator
    Implements
    IIdGenerator
    Namespace: Kros.Data
    Assembly: Kros.Utils.dll
    Syntax
    public abstract class IdGeneratorBase : IIdGenerator, IDisposable

    Constructors

    IdGeneratorBase(DbConnection, String, Int32)

    Creates an instance of ID generator for table tableName in database connection and with specified batchSize.

    Declaration
    public IdGeneratorBase(DbConnection connection, string tableName, int batchSize)
    Parameters
    Type Name Description
    System.Data.Common.DbConnection connection

    Database connection.

    System.String tableName

    Table name, for which IDs are generated.

    System.Int32 batchSize

    IDs batch size. Saves round trips to database for IDs.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Value of connection or tableName is null.

    System.ArgumentException

    Value of batchSize is less or equal than 0.

    IdGeneratorBase(String, String, Int32)

    Creates an instance of ID generator for table tableName in database connectionString and with specified batchSize.

    Declaration
    public IdGeneratorBase(string connectionString, string tableName, int batchSize)
    Parameters
    Type Name Description
    System.String connectionString

    Database connection string.

    System.String tableName

    Table name, for which IDs are generated.

    System.Int32 batchSize

    IDs batch size. Saves round trips to database for IDs.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Value of connectionString or tableName is null.

    System.ArgumentException

    Properties

    BatchSize

    Batch size - saves roundtrips into database.

    Declaration
    public int BatchSize { get; }
    Property Value
    Type Description
    System.Int32

    Connection

    Database connection.

    Declaration
    protected DbConnection Connection { get; }
    Property Value
    Type Description
    System.Data.Common.DbConnection

    TableName

    Table name for which IDs are generated.

    Declaration
    public string TableName { get; }
    Property Value
    Type Description
    System.String

    Methods

    CreateConnection(String)

    Creates a database connection instance.

    Declaration
    protected abstract DbConnection CreateConnection(string connectionString)
    Parameters
    Type Name Description
    System.String connectionString

    Connection string.

    Returns
    Type Description
    System.Data.Common.DbConnection

    Specific instance of System.Data.Common.DbConnection.

    Dispose()

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    GetNewIdFromDbCore()

    Returns new ID from database. In this method is ensured, that the Connection is opened.

    Declaration
    protected abstract int GetNewIdFromDbCore()
    Returns
    Type Description
    System.Int32

    Next ID.

    GetNext()

    Declaration
    public virtual int GetNext()
    Returns
    Type Description
    System.Int32

    InitDatabaseForIdGenerator()

    Declaration
    public abstract void InitDatabaseForIdGenerator()

    Implements

    IIdGenerator

    See Also

    IIdGenerator
    Back to top KROS a.s.