To inform you the reality, I’ve not likely labored with Digital Entities, ever because it was launched, and I might have plenty of causes to truly use them, it simply by no means appeared the proper time. Within the latest launch, I truly did my very own little PoC to find out the complexity, and if it was at all times that straightforward, most likely one thing to remorse.
Let’s soar into it. Digital tables (or Digital entities) have been out there for fairly a while now, however just for learn entry. Now with the addition for Create, Replace and Delete, this provides us for entry to integrating between our Dataverse atmosphere and a publicly out there SQL Server (or different platform). In at present’s put up we are going to present easy methods to undergo the method of making the SQL Server desk, creating the plugin, knowledge supplier, knowledge supply and eventually the digital desk an connecting all of the items collectively.
The entire supply code on this put up is proven in photos, however might be out there by way of the Github Hyperlink on the backside of the put up.
Let’s begin with the database. On this case I used an Azure SQL database, and created a desk known as Service Request. The script for creating the desk is proven beneath.
Subsequent we create a Plugin Undertaking in Visible Studio. You’ll need to put in the next packages in your undertaking to be able to get entry to all the required assets (per Microsoft documentation):
Throughout the plugin we are going to create 6 Lessons. The primary is a static class containing the Connection code, and the opposite lessons are every for a message (Create, Retrieve, RetrieveMultiple, Replace, Delete). You may create them as a single file or in a number of recordsdata. For the demonstration they’re all created in separate recordsdata.
The next utilizing statements have been added to all recordsdata, though not all is required for all lessons.
Let’s begin with the Connection class. We use the SqlConnectionStringBuilder class to generate the Connection string and return it to the remainder of the lessons that may eat it. That is proven within the picture beneath.
Subsequent, let’s have a look at the CRUD lessons. The entire lessons implement the IPlugin interface and name the Execute perform of that Interface. In every of the category based mostly on the required performance we retrieve the Execution Context to be able to learn knowledge from the Dataverse atmosphere, after which synchronize between our Dataverse atmosphere and our Azure SQL Server. The screenshots beneath present the code for every of those.
Retrieve A number of Class:
As soon as the code for the Plugin is accomplished we are going to go forward and register the plugin by way of the Plugin Registration Software. Earlier than registering the plugin, just be sure you have the most recent model of the Plugin Registration Software that gives assist for CRUD operations in digital tables. On the time of penning this put up, the required model was 22.214.171.124. You could find the obtain hyperlink beneath:
Now let’s go forward and register the Plugin. This could embody all the 5 messages above. As soon as the Plugin is registered, we go forward and Register a brand new Information Supplier (utilizing the Plugin Registration Software).
Click on on the Register button, and choose Register New Information Supplier (Ctrl + P).
When deciding on the Information Supply Entity for the primary time, select the Create New from the drop down. You will need to choose the answer that accommodates the writer that has the prefix that you simply need to use, or you’ll have to modify you code for one thing else.
As soon as we’re performed with creating the info supplier within the Plugin Registration Software, we will go forward and begin organising the Digital Desk in our Dataverse atmosphere. This performance is just not out there but within the Maker Portal, so we must do that within the Basic interface (Superior Settings).
Navigate to Settings and Administration, and choose the Digital Entity Information Sources, and click on on the New button. A popup will seem with a drop down to pick out a Information Supplier as proven within the picture beneath.
Choose the title of the Information Supplier that you simply chosen, and click on on the OK button. Then it is possible for you to to supply a reputation for the Information Supply.
Click on on Settings once more and choose Options. Choose the title of the answer the place you need to create the fields for this desk. Verify the Digital Entity choice, and choose the Information Supply that you simply simply created. Enter a Show Identify, Plural Identify and Identify for the entity. You’ll discover that there are two further Names that are the Exterior Identify and the Exterior Assortment Identify. For the Exterior Identify, it is best to enter the title of the Supply desk. The Exterior Collections title can comprise the identical values because the Plural desk title.
After you have completed creating the desk, go forward and create all the columns that you’re going to use to view or replace inside the Digital Entity. Solely add columns that you simply need to both learn out of your Azure SQL desk or that you simply need to write again. Any columns which are for administration solely usually are not actually required. The picture beneath present the columns that had been created for our take a look at:
Subsequent, we have to add this entity to our Mannequin Pushed App, in order that we will take a look at this out. Choose an current MDA or create a brand new one and add the entity to it.
Lastly go forward and take a look at the outcomes.
The animated screenshot above reveals including, studying and updating entity fields utilizing CRUD operations.
You may click on on the hyperlink beneath to get entry to the Supply Code: