Hello, everyone, and welcome back to Microsoft Dynamics 365 or CRM interview questions and answers
video series in today's video.
We'll see what is late binding and early binding programming in Dynamic 365.
So basically in today's agenda, first of all, we will see an overview about what is late binding and early binding
programming with
6
00:00:19,890 --> 00:00:21,300
respect to Dynamics 365.
And then I will show you I'll show you a practical demo how you can use late binding and early binding in Dynamics
365 by working with C#.
And then I will show you how you will choose or in which scenarios you can choose, which is there any
specific guidelines for that?
And lastly, we will see what's next.
That means that we will cover which topics that you want us to cover in our next videos.
Ladies and gentlemen, my name is Abhishek Dhoriya and you are watching Dynamix Academy YouTube Channel.
So let's get started.
Subscribe to Dynamix Academy and Press the bell icon on YouTube.
So that You have never miss a video from Dynamix Academy.
So first of all, I will give you an overview about what is late binding and early binding with respect
to dynamics 365.
So when you are working with organizations, services, assemblies, you can choose either of two types.
It is late binding or early binding programming.
Basically, the difference between early and late binding programming is that respect to type conversion.
So let us know.
Understand what is late binding?
The text only when the object is created or and the type casting is performed on the run time.
So basically the type of a variable or type of an object you will not come to know untill runtime.
So you will not come to know the type of the variables and objects until runtime.
Well, in case of late binding programming the checking of all types so that there is no implicit
type cast occur.
So you will be able to know the types of the objects and variables at the compile time.
So you do not need to embrace type typecast anything.
So let us now.
understand late binding in detail. the late binding programming uses entity class and you need to refer to entities
and attribute using the logical end property values.
For example, let's say if you want to get the logic of that entity, then you can use entity metadata,
not logical.
Or if you want to attribute names and you can find using attribute metadata, logical and in the relationship
do not have logical property.
So to retrieve the relationship name, you can use relationship metadata based on schema and property.
Let me give you a glimpse of how late binding program looks like.
Here you can see you have declared a variable called account using entity class where you have passed
the account as a parameter account is an entity within your dynamics instance
And let's say if you want to set the name of the account, you can use this to index.
You have to use this index where you need to know the attribute logical and you need to know each and
every attribute that you are using or that this particular entity is having.
And if you are setting the property, then you need to use that property or you need to know the name
of the particular property.
This is an example of a name is a type of thing or a boolean or whether it is no.
Or that you cannot determine by looking at the code.
Right.
But you need to know while setting up the values of this particular attributes.
Otherwise it may fail.
You are setting a boolean value to your string attribute, then it may fail.
So in this case, you need to know the type of the attributes that you are using in your code properly.
So having said that, let us know, understand what are the advantages of this particular style of programming?
The main advantage for Late bound programming is that you do not need to generate the classes or include
the generated file within your project because sometimes the file can become quite large.
That's the main advantage that you do not need to do any extra specific activities in order to generate
the relevant early bound classes.
But at the same time it has some sorts of disadvantages as well.
So let us now have a closer look at those disadvantages.
The number one disadvantages you have is you do not get the compilr time validation of names of entities,
attributes and relationships.
That means, let's say, if you have forgotten or you have misspelled some of the names of the attributes
within your code, still, your order will compile properly and it will fail only at the run time.
So that is one of the biggest disadvantage.
And lastly, the other disadvantage is that you need to know the names of the attributes.
And relationships in metadata, while writing your code itself, you need to know the types and the names
correctly while writing your book because you will not get any sort of assistance using the intellisense
from visual studio.
But in case of early binding programming, you will get some sort of intellisense from your visual studio.
So let us know.
Understand what is early binding program.
So early bound programming requires that you first generate a set of classes based on the metadata for
a specific organization using code generation tool, which in CRM case is CRMSVCUtil.exe.
Many of you would be doing this, but still there are some users who don't know how to use this utility.
So in today's video, I will show you how to generate early binding classes using crmsvcutil and add it into your
project as well.
And from where you can find this tool and how to use it properly.
So all these things we are going to cover in the demo.
And once you have generated the early bound and the class classes using the code generation tool, then
you will enjoy a better experience while you are writing a code, because classes, attributes and relationship
all uses the same property values.
For example, in case of if you want to find the identity name, then you can still use the schema name
property at all, whether it is entity or relationship metadata.
Let me show you names of early bound classes as well.
So now you can see I'm declaring an account variable using the account classic.
Earlier I had to use entity class now since I was in the early bound classes.
Now I can directly use the account plus and I can directly use account code once I put the card and
it will use all the tools and attributes into to do Intellisense and I can set the properties directly
and here you can get the type of the as well.
So it would be very easy and convenient where you are using rebounding classes.
So let's look at some of that.
You can simply instantiate the class and let the Intellisense individual.
You provide the names of the properties and relationships at the same time.
Some of the disadvantages are you need to generate a live on classes every time you make any customization
changes.
And sometimes these generated files can become quite large.
So these are the two main disadvantages for this style of programming.
So having said that, let me show you a step by step demo of both late printing and binding programming.
This is my visual studio and for the moment, I have created a project of control application to this
process.
You already know how you can create a project of console application and you need to read the required
references.
And from where you can get those required microsoft.crm.proxy.dll and xrm.tooling.connector references, you
can get it from the SDK.
So you need to have three important prerequisites before you start practicing this Step-By-Step demo
number one, which is you must have downloaded the Dynamics 365 by SDK in your local PC.
So if you want to know how you can download and install the new machine, then you can watch the video
link is given on the top of the screen.
Once you download it, you will be able to these references.
I once again emphasize that you need to download the locally because you will be requiring the SDK when
you want to work with the binding classes, because as we have seen in previous step, that you need
to generate some early binding classes with the help of one tool called CRM as we see util.
So that utility you will get only in the SDK itself.
So you must install the dynamics are still very much an nine point or SDK.
The next set of requirement is you must have a trial to practice it, or if you have a optimisations,
then it is fine.
But at least you should have a dynamic solution, for instance, to connect with in your code.
So if you want to set up a dynamic system for that, also, we have prepared a video.
You can check out the link given on the top of your screen.
And lastly, you must know how to connect to the dynamics to Petrelis just using C support.
So for that also, we have prepared a Step-By-Step video of how you can connect to your dynamic 365
using sheesha.
This is my program, dodgiest file of that particular project where the very first thing which I'm doing
is I'm establishing a connection using the connection string and ceramicist.
So I'm not going to explain it.
Once again, if you want to check in detail, you can click the video link even on the top of your screen
that I explained step by step how you can connect and understand this code properly.
So this line of code is for the connecting to my dynamic, for instance.
And next, if the connection is successful, then what?
I am printing one message board connection successful.
And then the very first matter I'm navigating is Finding Nemo.
So this is my lead mining demo.
So here you can see I am, first of all, declaring an object of an entity class.
And in that entity, class constructor, I am passing a string parameter called account.
This account is nothing but the logical entity, entity, logical name of the account which is present
in my dynamic's fatalities.
Once I declare that object, then.
And it was hard to attribute certain parameters to the field values that you want to set for that particular
report, which you are going to create.
So you need to know what the logical name of the entity logical or the schema name on all the attributes
that you are going to use, as well as not only the name, but even the type of the attributes which
you are using because you will not be able to know the type of these particular attributes while writing
the code.
So since the name attribute is of string type, I need to parse the string value again, credit on hold
is another Boolean type or two options at value in my demonstration, for instance.
So I am passing fault here.
Last on hold.
Time is a daytime value, so I need to pass the value in the same format.
Again, this latitude and longitude and passing into the format again, number of employees is an integer
while the remaining feliza monetized.
So I need to pass.
I need to make sure that that conversion should be proper while writing the code itself.
Because if I make any mistake in the conversion or in the spelling of the attributes or the entity,
the code would compile correctly.
But while running the code will feel at the time of runtime, only the code value, it is not going
to validate on compiler.
But that's the classic characteristic of any programming.
So let me run this code and let's see if it is successful at getting created in the system or not.
So first you can see it the and successful and lastly, it has given me a gold record created successfully
and I'm opening a new record jewelry which has been created.
So let us know the Human Dynamics 360, for instance, and check if any such account with this name
has been created today or.
This is my dynamic stress test, so I'm navigating to the companies in this instance, I rename accounts
as companies that display them or their contest companies to.
Now you can see a new record has been created called Controversal.
And you can check out that information as well and check the annual revenue number of employees on the
user through which we created this about customer order details you can find here.
We have really don't always know.
So now you can see.
Everybody's is getting successful, this is how you can run the let go.
Let me show you one more thing.
Let's see if I'm making a mistake in the name of this one.
So what will happen?
So whether this program is going to fail while compiling the code itself or it will fail at the wrong
time.
So if it is failing at compile time, then it will not build successfully.
So let me run this out.
Deliberately made a mistake and let's see if it is compelling, successfully or building successfully.
Now you can see the is compiled successfully and it is running properly and it has even given this message
connection successful.
So it has not validated by compiling the results.
And now you can see it has given me an error message.
When I'm creating this record, it is showing me clearly accountant.
It does not contain attribute rate name because in the end so this is the deliberate spelling mistake
which I have made.
There is no such attribute with name called a name.
So that's why it is getting failed here.
So this is how this is one of the drawbacks of this particular style of programming produced.
You will not be able to know that you have made any mistake by compiling the code itself.
So I'm stopping it again and let me know, fix this back.
So once I fix fixes back, it will run successfully.
So having said that, it does no see another style of programming called early findings on commenting
this and.
Showing you early painting, but as we were saying earlier, that for using early branding, you need
to first generate the early pine glasses.
So how you can reduce or eliminate the glue that you need to use and EXI, which is supplied in your
STK folder.
So let me show you how you can generate those are really binding classes.
So to generate that, you need to get to the dynamics recertified SDK.
I downloaded my dynamic's this get into this particular folder and here you can see or else the moment
you make it to the Corpuz folder of Biodynamics SDK, you will see a utility called CRM as we you need
to run this or this utility along with some specified parameters.
So what are those parameters?
Let me show you how you can run this.
You can follow this official Microsoft Dynamics through software documentation, which tells you how
you can generate early binding classes for your organization service.
Right, so you can follow this process step by step here and you can copy this example and you need
to replace the parameters, you are the parameters and username and password parameters instead of yours.
First of all, out of the keys and now make changes to this plan, which is you need to change that.
You specify the output file, which part you want to generate, the output file and with what name.
Here you need to specify the output file location in the name of the genetics code, which you need
to include into your project once it is genetic.
So here you can do but along with the output file, if you only to file and it will go to the file where
the system is located.
So let me know.
Change this file if you need to pass your username password.
If you want to use any namespace, you can specify the namespace or you can leave blank as well.
You can remove this parameter.
And if there's a better service context, namely if you specify the namespace here, then you need to
by adding this class with this specify using statement.
Is this what it is?
That is it.
Then what you need to do is you go to your run command in Navy, navigate through the folder where your
system, as we see it is posted
this copy your best.
No negative to the actual location here, no copy.
It is complete line of code and it under.
Once you hit enter, it will take time and you can see it started generating early classes once it is
done.
It will give a message here.
So now you can see a message.
It's clearly written that the code has been written to this particular part and this particular generator
to useful.
You can never get to that spot and check where the text file is present.
And once it is present, you need to add this same iest file into your project.
Now you can see it is generated and our own class is dodgiest file.
See it and it will be present where your ceramicist is located.
Now, what I need to do, I need to urge this class into my console application.
I open my studio back.
Now you need to repeat an existing item.
Here you need to navigate once again to get to the same location where your new religion class is present
selected, and every once a class has been added to your project in order to use that, you need to
use using different.
Using.
I call this my is nothing but the namespace which are defined by generating your early class.
No, get to my branding demo function in this matter.
Now you can see I am declaring the same object or account for this time.
I'm not using the entity class, but instead of that one.
So Ed classes and record names, faces, I can directly create an object of account class and simply
know what I can do, uses I can.
I do not need to remember the attributes which are present in that particular class.
It will directly take it up from the Intellisense itself.
Let's see if I want to set the name and if I type account.
And now you can see my results itself has picked up the required Intellisense.
I want to say this is the name of the regular school work and at the same time here you can see the
type of the attribute as well.
So since the credit on board is fully intact here, you can see it is that boolean.
It is OK string.
This is of eight times.
So this comes very handy.
Once you start writing your code, it is highly recommended that you use only printing classes to avoid
mistakes like programming or so I just changed the name here,
so I'll change the name to conduct early Finding Nemo.
So let me know on this program is printed record connection successful?
And next, it is correct.
The record created successfully.
It is a public statement only bending enough that it is the good stuff and we don't get to biodynamics.
That sounds very primitive.
That could be a creator once again and negative.
Back to my attorney says I'm opening all accounts and here you can see a new record with the name of
your them demo has been created successfully.
So this is how you can use Lebannon Dynamics 365 programming.
Let's say if I do the same mistake here, if I deliberately do not use this particular attribute name
correctly, then maybe just for the instance itself is started giving me an error warning.
So it is telling me that it does not contain any attribute or any definition with a name.
So let's say even though if I'm building or even if I'm learning, it is not going to run, it will
fail at the time of compiling it.
So it will not go successfully.
And it is tone and error will itself is failed.
So this is how it becomes very much handy when you are using my name in your dynamic's recording or
having seen the demo.
Let us now see how you can choose whether to use laid binding or binding in your dynamics to a project
will see the basic differences between both early binding and late Friday.
In case of early binding, you can verify entity attribute and relationships names at the compiler,
but in case of late binding, there will be no compile time verification of entity attributes and relationship
names.
So you need to know the names of entity attributes censorships in case of binding the differences.
You must gender identity classes when you are working with early bounding classes.
But there is no such requirement or you do not need to generate the entity classes for late bonding
programming.
Early branding provides a better Intellisense support for your visual studio, but there is no such
intelligence support in case of late programming, in case of early morning programming, you have to
do less.
But the code would be more readable.
But in case of late morning, you have to work more, but the code will be less readable.
While another difference you might need to keep in mind is that early on programming are a slightly
less performance than that in case of late Bown programming.
But still, we recommend you to use Ahlborn programming because it would help you to write clean code
and more readable.
You can see the clear differences between early morning and late binding programming style.
But it depends really on the developer each day they want to use.
And at the same time you can even mix both early and late founding programming in your code itself,
because all the gender class inherited from the entity class which used Lightbown programming you can
work with.
And it is attributes and relationships not defined within the classes as well.
By that what we mean is so once you generate the classes in case of early binding programming, all
these general classes will inherit from the entity class itself.
So entity class is nothing but a binding program.
So this is an example which shows how you can mix early and late binding methods using organizing service
context.
So first of all, I am declaring my context, creating an organization service context here.
Then I am declaring late binding test account and within test account I'm putting to binding at the
group's name and immolators at the same time.
I'm adding a concept.
A concept is nothing but the bound class and then and making the same changes here.
This is the way you can mix early and late binding while other milvia you can mix is, let's say if
you're declaring a binding variable and you can forward to regenerator classes after adding one attribute
to that entity, you can still use that attribute in your code using the program.
So here I am using the name parameter.
The first name is nothing, but the only band activated by the simple custom boolean is a new field
or an attribute that to the second class.
But I am not regenerator and that of course I'm simply using in my for little newly generated attribute
and then I can use to create in simple manner.
This code is also perfectly okay.
And if we can do this two ways, you can mix early and late binding by putting your dynamic 365 program.
Let us now see what's next, particularly in late morning programming.
So if you still have any queries or concerns, please put them in the comment box below.
We are happy to answer all your questions and at the same time, please help us in deciding the next
video.
If you want us to prepare a video on our platform and type our platform in the comment box of this video,
or if you want to know about the dynamics, Social Security Dynamics, 360 Security in the comment box
of this video, if you want to connect with us, then you can find the links of all social media platforms
in the description box specially you would like to connect with us on the waterproofed.
People are actively participating and posting their queries where they will get life support and feedback.
So having said that, I end this video and.
So if you learn something new out of this video, then please, like share and subscribe to Dynamic's
Academy and also press the Billiken so that you will never miss any update whenever we release a new
video to our Dynamics Academy, YouTube channel.
And on that note, I ended this video and take your new hope to see you all in the next video.
Till then, bye bye and take care.
And once again, thank you for your time.
