Class NumericKeyGenerator
- Namespace
- Breeze.Persistence
- Assembly
- Breeze.Persistence.dll
Generates numeric primary keys from a single-row NextId table in the database.
public class NumericKeyGenerator : IKeyGenerator
- Inheritance
-
NumericKeyGenerator
- Implements
- Inherited Members
Remarks
Ids are handed out in blocks so that most saves need no database round trip. Claiming a block is a select followed by a conditional update, retried if another process took the block first, so several servers can share one table.
Constructors
NumericKeyGenerator(DbConnection)
Create a generator drawing ids from the NextId table on a connection.
public NumericKeyGenerator(DbConnection dbConnection)
Parameters
dbConnectionDbConnectionThe connection to use. It is opened and closed as needed if it is not already open.
Methods
UpdateKeys(List<TempKeyInfo>)
Assign a real key value to each entity, converted to that key property's type.
public void UpdateKeys(List<TempKeyInfo> keys)
Parameters
keysList<TempKeyInfo>The entities needing keys.
Exceptions
- NotSupportedException
A key property is of a type a number cannot be converted to.
- Exception
The
NextIdrow is missing, or could not be claimed after several attempts.