Mixing early-binding and late-binding with nameof operator in C# [CRM]
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!
Filed under: Microsoft Dynamics 365
This was originally posted here.

Like
Report
*This post is locked for comments