Using Latebound Constants Generator

1 Comment

The Latebound Constants Generator is a tool by Jonas Rapp to generate constant classes for late bound Dynamics 365 development.

To use it, open the XrmToolBox and install “Latebound Constants Generator”:

This will install:

Select the link, you will see below. Click Load entities:

This will load the entities and selected entity attributes:

Note the ability to filter entities by Solution, whether to show system or customized entities, managed or unmanaged, etc:

Note the options for how the file will be geneated. Select an output folder for where the file will be generated, and also specify if you would like one file per entity or not. You can also specify the file name, and a namespace. We will use Carl.LateBoundGen:

Under Constant Options, note the ability to specify the identifier to use (Logical Name, Display Name, Schema Name), whether you want Attributes output etc:

Adding XML documentation for properties and description will output:

In the Attributes section you can specify whether to include the Primary Key and Primary Attribute:

Including this outputs:

Running the tool, we get a file output something like below, with the Account class and Contact selected and generated:

With option sets:

Next, we will use this in a Visual Studio solution.

In Visual Studio, create a console app called Carl.LateBoundGen:

This will create:

Add the file generated:

Add the Dynamics 365 Core Assemblies and XrmTooling through NuGet:

Now we will create some code. Take a look at some Linq code I wrote previously. This code hardcodes constant values such as the entity name and attributes:

Instead, we will reference these constants through our new file. Take a look at the new code – instead of “account” we can use Account.EntityName, for example:

Running this produces:

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

One Response to Using Latebound Constants Generator

Leave a Reply

Your email address will not be published. Required fields are marked *