Sequences
Read the next values of SQL Server sequences.
On this page
What are Sequences?#
This feature in The Sharp Factory Framework allows the developer to call SQL Sequences.
Sequences in SQL generate sequential numbers much like Identity fields. These incremental numbers are global to the entire database.
These sequences are bound to a particular SQL Schema.
The Sharp Factory App generates a method per SQL Sequence added to the model.
The naming convention is RepositoryContainer.{Model Name}.{SQL Schema}.Sequences.{Sequence Name}
Calling Sequences#
The following C# code sample shows how to consume a SQL Sequence called CustomerID.
C#
// declare an instance of the Repository Container// remember this can be a singleton if you// declare it early on and reuse it for the// lifetime of your applicationvar repo = new RepositoryContainer();// call the sequence called CustomerID and get the next numbervar nextNumber = _repo.AppDb.Sales.Sequences.CustomerID();// do something with the next sequential number