I have following statement:
queryPublications += $" AND CC_Publication__r.CC_External_ID__c IN ({inPublicationExtIds})";
Now i want to use the nameof expression to get compile time safety for the names, for the case that smething will change in future. But the modified code doesn't look nicely anymore:
queryPublications += $" AND {nameof(CC_Publication_Subscription__c.CC_Publication__r)}.{nameof(CC_Publication_Subscription__c.CC_Publication__r.CC_External_ID__c)} IN ({inPublicationExtIds})";
Consider that there are more fields or the property-path(what's the correct term?) is even longer:
AND Class1.Prperty1.Class2.Property2.Class3.Property3 IN
The code becomes really ugly and you can easily make mistakes. You have to repeat the whole part that comes before the current.
Is there any way(extension or technique) to simplify my approach?
Would be great if there was a fullnameof to get the full path.