I've seen this question posted a number of times here but I don't think I understand the solution as it related to my problem.
I'm getting the exception on this line:
return CurrentCompany.ParentCompanyId == null
? (Guid)CurrentCompany.ParentCompanyId
: CurrentCompanyID;
Here's more of the code:
/// Return the current company id, unless this is a child company id,
/// then return the parent company id.
private Guid MainCompanyID
{
get
{
return CurrentCompany.ParentCompanyId == null
? (Guid)CurrentCompany.ParentCompanyId
: CurrentCompanyID;
}
}
I'm happy to share more if needed but this is about the extent of the stack trace.
!= nullinstead of== null.!=instead of== null. You could also use the null coalescing operator instead:return CurrentCompany.ParentCompanyId ?? CurrentCompanyID.