The Auto Incrementing ID Module allows developers to quicky add incrementing IDs to business objects.
Getting Started
Install the LlamachantFramework.AutoIncrementingID.Module from NuGet into your solution
Include LlamachantFrameworkAutoIncrementingIDModule to your .Module project.
public DXApplication1Module() {
RequiredModuleTypes.Add(typeof(LlamachantFrameworkAutoIncrementingIDModule));
}
By using an event handler, one can determine SQL queries of when the incrementation is triggered or created by using TriggerCreating or TriggerExistence.
In this sample business object, the AutoIncrement attribute without parameters has the ID increment off the largest integer value stored in the database.
[DefaultClassOptions]
public class Quote : BaseObject
{
public Quote(Session session)
: base(session)
{
}
private int _ID;
[AutoIncrement]
public int ID
{
get { return _ID; }
set { SetPropertyValue(nameof(ID), ref _ID, value); }
}
private string _CustomerName;
public string CustomerName
{
get { return _CustomerName; }
set { SetPropertyValue(nameof(CustomerName), ref _Name, value); }
}
}
Users can add a parameter to the AutoIncrement attribute so the ID will be dependent on the uniqueness of a variable, such as a CustomerName.
[AutoIncrement(nameof(CustomerName))]
The AutoIncrement attribute can take any number of parameters and will increment off the largest integer value stored in the database that matches values of those parameters, such as incrementing based on a CustomerName and a DateTime variable.