public async Task TestSpecialCharactersInPrimaryKey() { var client = new DataServiceContext(new Uri(this.BaseAddress)); client.Format.UseJson(GetEdmModel()); var query = client.CreateQuery <SpecialCharactersLinkGenerationTestsModel>("SpecialCharactersLinkGenerationWebTests"); var todoes = await query.ExecuteAsync(); bool success = true; foreach (var todo in todoes) { try { Uri selfLink; Assert.True(client.TryGetUri(todo, out selfLink)); Console.WriteLine(selfLink); await client.ExecuteAsync <SpecialCharactersLinkGenerationTestsModel>(selfLink, "GET", true); } catch (Exception ex) { Console.WriteLine(ex); success = false; } } Assert.True(success); }
public async Task TestSpecialCharactersInPrimaryKey() { var context = new DataServiceContext(new Uri(this.BaseAddress)); context.Format.UseJson(_model); var query = context.CreateQuery <SpecialCharactersLinkGenerationTestsModel>("SpecialCharactersLinkGenerationTests"); var todoes = await query.ExecuteAsync(); bool success = true; foreach (var todo in todoes) { try { Uri selfLink; Assert.True(context.TryGetUri(todo, out selfLink)); Console.WriteLine(selfLink); var result = await context.ExecuteAsync <SpecialCharactersLinkGenerationTestsModel>(selfLink, "GET", true); var fetchedTodo = result.FirstOrDefault(); Assert.NotNull(fetchedTodo); Assert.Equal(todo.Name, fetchedTodo.Name); } catch (Exception ex) { Console.WriteLine(ex); success = false; } } Assert.True(success); }
/// <summary> /// Cancels the async. /// </summary> /// <returns>A function delegate that returns the future result to be available through the Task.</returns> public Task CancelAsync() { if (string.IsNullOrWhiteSpace(this.Id)) { // The job was not submitted yet. throw new InvalidOperationException(StringTable.InvalidOperationCancelForNotSubmittedJob); } Uri uri = new Uri( string.Format(CultureInfo.InvariantCulture, "/CancelJob?jobid='{0}'", HttpUtility.UrlEncode(Id)), UriKind.Relative); DataServiceContext dataContext = this._cloudMediaContext.DataContextFactory.CreateDataServiceContext(); dataContext.IgnoreResourceNotFoundException = false; dataContext.AttachTo(JobBaseCollection.JobSet, this); return(dataContext .ExecuteAsync <string>(uri, this) .ContinueWith( t => { t.ThrowIfFaulted(); JobData data = (JobData)t.AsyncState; data.JobEntityRefresh(dataContext); })); }
public virtual void InvokeActionWithOverloads(string actionUrl) { DataServiceContext ctx = new DataServiceContext(new Uri(this.BaseAddress), ODataProtocolVersion.V4); var result = ctx.ExecuteAsync(new Uri(this.BaseAddress + actionUrl), "POST").Result; Assert.Equal(204, result.StatusCode); }
/// <summary>Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.</summary> /// <returns>A task represents the result of the operation. </returns> public Task <IEnumerable <T> > ExecuteAsync() { return(Context.ExecuteAsync <T>(this.RequestUri, XmlConstants.HttpMethodPost, false, Parameters)); }
/// <summary>Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.</summary> /// <returns>A task represents the result of the operation. </returns> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> public Task <OperationResponse> ExecuteAsync(CancellationToken cancellationToken) { return(Context.ExecuteAsync(this.RequestUri, XmlConstants.HttpMethodPost, cancellationToken, Parameters)); }
public async Task TestSpecialCharactersInPrimaryKey() { var client = new DataServiceContext(new Uri(this.BaseAddress)); client.Format.UseJson(GetEdmModel()); var query = client.CreateQuery<SpecialCharactersLinkGenerationTestsModel>("SpecialCharactersLinkGenerationWebTests"); var todoes = await query.ExecuteAsync(); bool success = true; foreach (var todo in todoes) { try { Uri selfLink; Assert.True(client.TryGetUri(todo, out selfLink)); Console.WriteLine(selfLink); await client.ExecuteAsync<SpecialCharactersLinkGenerationTestsModel>(selfLink, "GET", true); } catch (Exception ex) { Console.WriteLine(ex); success = false; } } Assert.True(success); }
public static async Task <QueryOperationResponse <TEntity> > ExecuteAsync <TEntity>(this DataServiceQueryContinuation <TEntity> continuation, DataServiceContext context) { return((QueryOperationResponse <TEntity>) await context.ExecuteAsync(continuation)); }