This may be more of a .NET question potentially but it is certainly strange.
I have some old code in a Command Line App that I have dusted off which retrieves an Microsoft.Xrm.Sdk.Metadata.EntityMetadata object from Dynamics. In my case v8.2.
Basically a list of Entities and their Settings, Attributes etc.
I have some logic which applies the "Contains" method to the resulting object (currentEntity).
if (currentEntity.Contains("PrimaryNameAttribute"))
{
metadataWriter.WriteElementString("PrimaryNameAttribute", currentEntity.PrimaryNameAttribute);
}
The thing is, it is always false. This worked in the past. I can see the "PrimaryNameAttribute when I debug and the spelling/case looks correct.
The SDK version is 9.0.0.0 so it is later than the CRM Instance but I believe this worked maybe 2 years ago.
Bemused and annoying.
I can comment out the IF statements but this did work and I can see the attribute so it would be great to know what has gone wrong.