Max Schmeling
Domain service extension method
This little extension method is something I wrote to help cleanup domain context code… just thought I would share:
public static class DomainContextExtensions
{
public static void Load(this DomainContext domainContext,
EntityQuery query,
Action<LoadOperation> preprocessCallback,
Action<LoadOperation> successCallback,
Action<LoadOperation> errorCallback,
Action<LoadOperation> postprocessCallback = null)
where TEntity : Entity
{
domainContext.Load(query, load =>
{
if (preprocessCallback != null)
preprocessCallback(load);
if (load.HasError)
{
if (errorCallback != null)
{
errorCallback(load);
load.MarkErrorAsHandled();
}
}
else
{
successCallback(load);
}
if (postprocessCallback != null)
postprocessCallback(load);
}, null);
}
}
Enjoy!
-
Meta



