I'm on an upgrade project and recently began experiencing issues with the upgraded version of a DLL. I decompiled the original dll and found the following if statement:
if (fieldConfiguration == null && Context.ContentDatabase != null)
{
Item obj = Context.ContentDatabase.SelectSingleItem(
string.Format("//*[@@templateid='{0}' and @@key='{1}']",
(object) TemplateIDs.TemplateField, (object) fieldName));
}
I then decompiled the upgraded version of the DLL and the statement was as follows:
if (fieldConfiguration == null && (Context.ContentDatabase ?? Context.Database) != null)
{
Item obj = Context.ContentDatabase.SelectSingleItem(
string.Format("//*[@@templateid='{0}' and @@key='{1}']",
(object) TemplateIDs.TemplateField, (object) fieldName));
}
I was able to step through the code by decompiling the DLLs with dotPeek and using the dotPeek symbol server functionality. I can see that the code is failing when using the upgrade DLL because Context.ContentDatabase is null. What I don't understand is how that double ternary operator is evaluated. Could someone clarify for me what's going on there? It seems as though the creators of this assembly wanted a null check for Context.ContentDatabase but may have made a mistake. Thanks for the help!