I have a plugin that runs on an emails, it checks the sending contact for a parent account to then use that account on the case.
In the scenario where the contact doesn't have a parent contact, I'm getting an error even though I believe my short-circuited logic shouldn't evaluate the second expression
Entity eContact = service.Retrieve("contact", _sender.Id, new ColumnSet("parentcustomerid"));
tracer.Trace(eContact.Contains("parentcustomerid").ToString()); //returns false
foreach (KeyValuePair<string, object> att in eContact.Attributes) //only gives contact id
if (att.Value.GetType() == typeof(EntityReference))
tracer.Trace(att.Key + ": " + ((EntityReference)att.Value).Name);
else
tracer.Trace(att.Key + ": " + att.Value.ToString());
if (eContact.Contains("parentcustomerid") && eContact["parentcustomerid"] != null && ((EntityReference)eContact["parentcustomerid"]).LogicalName == "account")//Given Key not in Distionary error
{
tracer.Trace("Set Account");
eCase["dsg_account"] = (EntityReference)eContact["parentcustomerid"];
}






