Пример #1
0
        internal static QueryResult EndExecute <TElement>(object source, IAsyncResult asyncResult)
        {
            QueryResult response = null;

            try
            {
                response = BaseAsyncResult.EndExecute <QueryResult>(source, "Execute", asyncResult);
            }
            catch (InvalidOperationException ex)
            {
                response = asyncResult as QueryResult;
                Debug.Assert(response != null, "response != null, BaseAsyncResult.EndExecute() would have thrown a different exception otherwise.");

                QueryOperationResponse operationResponse = response.GetResponse <TElement>(MaterializeAtom.EmptyResults);
                if (operationResponse != null)
                {
                    operationResponse.Error = ex;
                    throw new DataServiceQueryException(Strings.DataServiceException_GeneralError, ex, operationResponse);
                }

                throw;
            }

            return(response);
        }
Пример #2
0
        internal static QueryResult EndExecuteQuery <TElement>(object source, string method, IAsyncResult asyncResult)
        {
            QueryResult result = null;

            try
            {
                result = BaseAsyncResult.EndExecute <QueryResult>(source, method, asyncResult);
            }
            catch (InvalidOperationException exception)
            {
                result = asyncResult as QueryResult;
                QueryOperationResponse response = result.GetResponse <TElement>(MaterializeAtom.EmptyResults);
                if (response != null)
                {
                    response.Error = exception;
                    throw new DataServiceQueryException(System.Data.Services.Client.Strings.DataServiceException_GeneralError, exception, response);
                }
                throw;
            }
            return(result);
        }