why on the 1st time load is the return GetProperty(EmployeeContactDetailsProperty); throwing an error:
InvalidOperationException was unhandled by user code? Its not a private backing field but only a child and lazy load object.
private bool IsLoadingEmployeeContactDetails = false;
private static readonly PropertyInfo<EmployeeContactDetailsEC> EmployeeContactDetailsProperty = RegisterProperty<EmployeeContactDetailsEC>(p => p.EmployeeContactDetails,
RelationshipTypes.Child | RelationshipTypes.LazyLoad);
public EmployeeContactDetailsEC EmployeeContactDetails
{
get
{
if (!IsLoadingEmployeeContactDetails)
{
if ((!FieldManager.FieldExists(EmployeeContactDetailsProperty) || ReadProperty(EmployeeContactDetailsProperty) == null))
{
IsLoadingEmployeeContactDetails = true;
ChildIsBusy = true;
#if SILVERLIGHT
if (!IsBusy)
MarkBusy();
if (IsNew)
{
//return EmployeeContactDetailsEC.NewEmployeeContactDetailsEC();
EmployeeContactDetailsEC.NewEmployeeContactDetailsEC(EmployeeID, (o, e) =>
{
if (e.Error != null)
throw e.Error;
EmployeeContactDetails = e.Object;
IsLoadingEmployeeContactDetails = false;
if (!IsBusyLazyLoading)
MarkIdle();
ChildIsBusy = false;
}
);
}
else
{
EmployeeContactDetailsEC.GetEmployeeContactDetails(EmployeeID, (o, e) =>
{
if (e.Error != null)
throw e.Error;
EmployeeContactDetails = e.Object;
IsLoadingEmployeeContactDetails = false;
if (!IsBusyLazyLoading)
MarkIdle();
}
);
}
#else
#endif
}
}
return GetProperty(EmployeeContactDetailsProperty);
}
private set
{
LoadProperty(EmployeeContactDetailsProperty, value);
OnPropertyChanged(EmployeeContactDetailsProperty);
}
}
Copyright (c) Marimer LLC