1. Home
  2. Docs
  3. Llamachant Framework Modules
  4. Additional Modules
  5. Auto Incrementing ID Module

Auto Incrementing ID Module

The Auto Incrementing ID Module allows developers to quicky add incrementing IDs to business objects. 

Getting Started

  1. Install the LlamachantFramework.AutoIncrementingID.Module from NuGet into your solution
  2. Include LlamachantFrameworkAutoIncrementingIDModule to your .Module project.
					public DXApplication1Module()  {        

By using an event handler, one can determine SQL queries of when the incrementation is triggered or created by using TriggerCreating or TriggerExistence.

					public override void Setup(XafApplication application) {
        application.SetupComplete += Application_SetupComplete;

    private void Application_SetupComplete(object sender, EventArgs e) {
        LlamachantFrameworkAutoIncrementingIDModule module = LlamachantFrameworkAutoIncrementingIDModule.FindAutoIncrementingModule(Application.Modules);
        if (module != null)
            module.TriggerCreating += Module_TriggerCreating;

    private void Module_TriggerCreating(object sender, LlamachantFramework.AutoIncrementingID.Module.Updaters.TriggerEventArgs e) {

Sample Object Implementation

In this sample business object, the AutoIncrement attribute without parameters has the ID increment off the largest integer value stored in the database.

    public class Quote : BaseObject
        public Quote(Session session)
            : base(session)

        private int _ID;
        public int ID
            get { return _ID; }
            set { SetPropertyValue<int>(nameof(ID), ref _ID, value); }

        private string _CustomerName;
        public string CustomerName
            get { return _CustomerName; }
            set { SetPropertyValue<string>(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.


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. 

					[AutoIncrement(nameof(CustomerName), "GetDate([QuoteDate])")]
Was this article helpful to you? Yes 1 No

How can we help?