web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :

Mixing early-binding and late-binding with nameof operator in C# [CRM]

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

nameof expression in C#6.0

 Bernado Nguyen-Hoan's Blog - Coding Stories from an IT Mercenary

There are many benefits of using early-binding when coding against CRM. There are times however when you need to fall back to late-binding, for example when you need to query relationships, or when you need to call Retrieve to optimise performance (as this service call allows you to load only selected fields of a record).

Rather than using literal string, you can use the nameof operator in C# 6 to get the attributes and relationship names. This works because the properties of the early-binding classes are generated based on the attributes and relationship names in CRM.

For example, to get the AccountNumber field of an Account record:

And there you have it: late-binding with all the early-binding zen!

View original post


Filed under: Microsoft Dynamics 365

This was originally posted here.

Comments

*This post is locked for comments