Using SelfServicing.
I have a scenario using the tables "DebtorGroup" and "DebtorGroupCompany"
DebtorGroup has a one-to-zero/one relationship to DebtorGroupCompany. i.e. for a DebtorGroup row, there will be either one or zero DebtorGroupCompany rows.
What I need to know is, once I've fetched a DebtorGroupEntity, does it have a related DebtorGroupCompany record or not.
Will this code work OK ?
IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.DebtorGroupEntity);
prefetchPath.Add(DebtorGroupEntity.PrefetchPathDebtorGroupCompany);
DebtorGroupEntity dg = new DebtorGroupEntity(DebtorGroupUID, prefetchPath);
if (dg.Fields.State == EntityState.Fetched)
{
// code removed for brevity
if (dg.DebtorGroupCompany.Fields.State == EntityState.Fetched)
{
// this code should only run when there is a valid related DebtorGroupCompany in the database
}
}
I guess my concern is whether dg.DebtorGroupCompany will be a null reference, or alternatively that by referencing it, it will create a new DebtorGroupCompany entity if one wasn't retrieved from the database.
Thanks in advance
Mike