/// <summary> /// Extension method to process the result of an asynchronous query operation. /// </summary> /// <param name="source"> The EntityQueryOperation returned from an asynchronous query. </param> /// <param name="onSuccess"> A callback to be called if the asynchronous query was successful. </param> /// <param name="onFail"> A callback to be called if the asynchronous query failed. </param> /// <remarks> /// This overload ignores the query results. It's typically used when calling a stored procedure, which doesn't return anything. /// </remarks> /// <returns> Returns the EntityQueryOperation passed to the method's source parameter. </returns> public static EntityQueryOperation OnComplete(this EntityQueryOperation source, Action onSuccess, Action <Exception> onFail) { source.Completed += (s, args) => { if (args.CompletedSuccessfully) { if (onSuccess != null) { onSuccess(); } } if (args.HasError && !args.IsErrorHandled && onFail != null) { args.MarkErrorAsHandled(); onFail(args.Error); } }; return(source); }
/// <summary> /// Gets an awaiter used to await this operation. /// </summary> /// <param name="operation"> The operation to await. </param> public static TaskAwaiter <IEnumerable <T> > GetAwaiter <T>(this EntityQueryOperation <T> operation) { return(operation.AsOperationResult().GetAwaiter()); }
/// <summary> /// Returns an implementation of <see cref="OperationResult{T}" /> that wraps a DevForce asynchronous function and provides access to the operation's result value. /// </summary> /// <param name="asyncOp"> DevForce asynchronous operation. </param> /// <returns> OperationResult encapsulating the provided DevForce asynchronous operation. </returns> public static OperationResult <IEnumerable <T> > AsOperationResult <T>(this EntityQueryOperation <T> asyncOp) { return(new EntityQueryOperationResult <T>(asyncOp)); }
/// <summary> /// Returns an implementation of <see cref="OperationResult{T}" /> that wraps a DevForce asynchronous function and provides access to the operation's result value. /// </summary> /// <param name="asyncOp"> DevForce asynchronous operation. </param> /// <returns> OperationResult encapsulating the provided DevForce asynchronous operation. </returns> public static OperationResult <IEnumerable> AsOperationResult(this EntityQueryOperation asyncOp) { return(new EntityQueryOperationResult(asyncOp)); }
private void LoadPageComplete(EntityQueryOperation args) { int pageIndex = UserStateToIndex(args.UserState); EndTrackPageLoading(pageIndex); if (args.HasError && !args.IsErrorHandled) { IsPageChanging = false; _tryRefreshItem = null; return; } // Only continue if this is the query for the page wanted right now. if (pageIndex != _requestedPageIndex) { return; } _requestedPageIndex = -1; IsPageChanging = true; PageIndex = pageIndex; // Innerlist is reloaded with each fetch - this is what will be displayed in bound control this._innerList.Clear(); foreach (var item in args.Results) { this._innerList.Add(item); } DoGrouping(); IsPageChanging = false; OnPageChanged(); OnPropertyChanged("PageIndex"); OnCollectionChanged(NotifyCollectionChangedAction.Reset, null, -1); // Reset position. For a refresh of a page will try to reset to last selected item. SetCurrentInfo(GetTryRefreshPosition()); }
public EntityQueryOperationResult(EntityQueryOperation entityQueryOperation) : base(entityQueryOperation) { _entityQueryOperation = entityQueryOperation; }