public CallMethodResult Execute(string methodName, IRepositoryMethodParameters parameters = null) { object methodResult; var resolveInfo = ResolveRepositoryMethod(methodName, parameters); try { methodResult = resolveInfo.Method.Invoke(resolveInfo.Instance, resolveInfo.Parameters); if (methodResult is Task task) { methodResult = TaskReflectionHelper.WaitForTask(task); } } catch (TargetInvocationException ex) when(ex.InnerException != null) { try { throw ex.InnerException; } catch (AggregateException e) { throw e.Flatten(); } } if (typeof(CallMethodResult).IsAssignableFrom(resolveInfo.Method.ReturnType)) { return(methodResult as CallMethodResult); } return(new CallMethodResult { Result = methodResult, ResultType = resolveInfo.Method.ReturnType, ResultIsHandled = false }); }
public async Task <object> FindAsync(Type entityType, params object[] ids) { return(await TaskReflectionHelper .WaitForTaskAsync((Task)FindAsyncMethodInfo.MakeGenericMethod(entityType) .Invoke(this, new object[] { ids })).ConfigureAwait(false)); }