1 month later, im also looking for an example. I tryed several possibilities, but there just doesn't seem to be an easy way?
Calling an factory method async and then in then loads the result whenever it comes back in a delegate seems more easier, but i believe i must be wrong ;)
Any example calling an child factory method within the LoadPropertyAsync would be appreciated.
Unfortunately the developer that built that feature has moved on to another stage of his career. This was his brain-child, and it isn't clear that the feature is directly valuable.
The basic concept was to support a lazy loading scenario. It was not designed to support multi-threading on the server (which seems to be what you imply by saying you want to use it with the child data portal). It is not designed for this.
The concept was to support lazy loading of a property value from the client by calling the data portal - or that's my understanding anyway.
I have never used the feature, and I don't honestly see where it is particularly important, given that there's already a perfectly good coding pattern to handle async lazy load scenarios.
I can see the value of the LoadPropertyASync, but i just couldn't figure it out how to use it.
At the moment i've the following code for a simple lazy child property.
Not using the RelationShip enum either, maybe we should.
This is way too much code for our monkeys, even with a snippet or codegen tool.
Is it possible to make a shorter version? Anyone with an idea?
#region Adressen
private bool _loadingAdressen = false;
internal static PropertyInfo<RelatieAdresList> adressenProperty = RegisterProperty(c => c.Adressen, "Adressen");
public RelatieAdresList Adressen
{
get
{
if (!_loadingAdressen && !(FieldManager.FieldExists(adressenProperty)))
{
if (this.IsNew)
{
_loadingAdressen = true;
RelatieAdresList.NewAdresList((s1, e1) =>
{
if (e1.Error != null)
throw e1.Error;
LoadProperty(adressenProperty, e1.Object);
OnPropertyChanged(adressenProperty.Name);
_loadingAdressen = false;
}
);
}
else
{
_loadingAdressen = true;
RelatieAdresList.GetAdresList(new RelatieAdresCriteria(Relatienummer), (s1, e1) =>
{
if (e1.Error != null)
throw e1.Error;
LoadProperty(adressenProperty, e1.Object);
OnPropertyChanged(adressenProperty.Name);
_loadingAdressen = false;
}
);
}
}
return GetProperty(adressenProperty);
}
}
#endregion
AdressenCopyright (c) Marimer LLC