Class MsAccessIdGeneratorFactory
Creates an instances of MsAccessIdGenerator for specified database.
Inheritance
System.Object
MsAccessIdGeneratorFactory
Implements
Namespace: Kros.Data.MsAccess
Assembly: Kros.Utils.MsAccess.dll
Syntax
public class MsAccessIdGeneratorFactory : IIdGeneratorFactory
Examples
public class PeopleService
{
private IIdGeneratorFactory _idGeneratorFactory;
public PeopleService(IIdGeneratorFactory idGeneratorFactory)
{
_idGeneratorFactory = Check.NotNull(idGeneratorFactory, nameof(idGeneratorFactory));
}
public void GenerateData()
{
using (var idGenerator = _idGeneratorFactory.GetGenerator("people", 1000))
{
for (int i = 0; i < 1800; i++)
{
var person = new Person()
{
Id = idGenerator.GetNext()
};
}
}
}
}
Constructors
MsAccessIdGeneratorFactory(OleDbConnection)
Initializes a new instance of the MsAccessIdGeneratorFactory class.
Declaration
public MsAccessIdGeneratorFactory(OleDbConnection connection)
Parameters
Type | Name | Description |
---|---|---|
System.Data.OleDb.OleDbConnection | connection | Connection, ktorá sa použije pre získavanie unikátnych identifikátorov. |
MsAccessIdGeneratorFactory(String)
Initializes a new instance of the MsAccessIdGeneratorFactory class.
Declaration
public MsAccessIdGeneratorFactory(string connectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | Connection string, ktorý sa použije na vytvorenie conenction pre získavanie unikátnych identifikátorov. |
Methods
GetGenerator(String)
Declaration
public IIdGenerator GetGenerator(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName |
Returns
Type | Description |
---|---|
IIdGenerator |
GetGenerator(String, Int32)
Declaration
public IIdGenerator GetGenerator(string tableName, int batchSize)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName | |
System.Int32 | batchSize |
Returns
Type | Description |
---|---|
IIdGenerator |
Register()
Registers factory methods for creating an instance of factory into IdGeneratorFactories.
Declaration
public static void Register()