- ( , ). , , . - ( ):
protected readonly IDictionary<Type, LoadOperation> pendingLoads =
new Dictionary<Type, LoadOperation>();
protected void Load<T>(EntityQuery<T> query,
LoadBehavior loadBehavior,
Action<LoadOperation<T>> callback, object state) where T : Entity
{
if (this.pendingLoads.ContainsKey(typeof(T)))
{
this.pendingLoads[typeof(T)].Cancel();
this.pendingLoads.Remove(typeof(T));
}
this.pendingLoads[typeof(T)] = this.Context.Load(query, loadBehavior,
lo =>
{
this.pendingLoads.Remove(typeof(T));
callback(lo);
}, state);
}
:
Load<Request>(Context.GetRequestQuery(id), loaded =>
{
// Callback
}, null);
:
, Ria Services (- , ). , , , Load , , , . ( , , ):
protected void Load(string queryName)
{
Type contextType = Context.GetType();
MethodInfo query = contextType.GetMethod(methodName);
Load(query.Invoke(this, null));
}
dataService.Load("GetUsersQuery");
... -...