当前位置: 首页>>代码示例>>C#>>正文


C# ODataBatch类代码示例

本文整理汇总了C#中ODataBatch的典型用法代码示例。如果您正苦于以下问题:C# ODataBatch类的具体用法?C# ODataBatch怎么用?C# ODataBatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ODataBatch类属于命名空间,在下文中一共展示了ODataBatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Success

        public async Task Success()
        {
            var x = ODataDynamic.Expression;
            var batch = new ODataBatch(_serviceUri);
            batch += c => c
                .For(x.Products)
                .Set(x.ProductName = "Test1", x.UnitPrice = 10m)
                .InsertEntryAsync(false);
            batch += c => c
                .For<Product>()
                .Set(x.ProductName = "Test2", x.UnitPrice = 20m)
                .InsertEntryAsync(false);
            await batch.ExecuteAsync();

            var product = await _client
                .For(x.Products)
                .Filter(x.ProductName == "Test1")
                .FindEntryAsync();
            Assert.NotNull(product);
            product = await _client
                .For(x.Products)
                .Filter(x.ProductName == "Test2")
                .FindEntryAsync();
            Assert.NotNull(product);
        }
开发者ID:rexwhitten,项目名称:Simple.OData.Client,代码行数:25,代码来源:BatchDynamicTests.cs

示例2: SuccessWithResults

        public async Task SuccessWithResults()
        {
            var x = ODataDynamic.Expression;
            dynamic product1 = null;
            dynamic product2 = null;

            var batch = new ODataBatch(_serviceUri);
            batch += async c => product1 = await c
                .For(x.Products)
                .Set(x.ProductName = "Test1", x.UnitPrice = 10m)
                .InsertEntryAsync();
            batch += async c => product2 = await c
                .For(x.Products)
                .Set(x.ProductName = "Test2", x.UnitPrice = 20m)
                .InsertEntryAsync();
            await batch.ExecuteAsync();

            Assert.NotEqual(0, product1.ProductID);
            Assert.NotEqual(0, product2.ProductID);

            product1 = await _client
                .For(x.Products)
                .Filter(x.ProductName == "Test1")
                .FindEntryAsync();
            Assert.NotNull(product1);
            product2 = await _client
                .For(x.Products)
                .Filter(x.ProductName == "Test2")
                .FindEntryAsync();
            Assert.NotNull(product2);
        }
开发者ID:rexwhitten,项目名称:Simple.OData.Client,代码行数:31,代码来源:BatchDynamicTests.cs

示例3: SuccessWithResults

        public async Task SuccessWithResults()
        {
            Product product1 = null;
            Product product2 = null;

            var batch = new ODataBatch(_serviceUri);
            batch += async c => product1 = await c
                .For<Product>()
                .Set(new Product() { ProductName = "Test1", UnitPrice = 10m })
                .InsertEntryAsync();
            batch += async c => product2 = await c
                .For<Product>()
                .Set(new Product() { ProductName = "Test2", UnitPrice = 20m })
                .InsertEntryAsync();
            await batch.ExecuteAsync();

            Assert.NotEqual(0, product1.ProductID);
            Assert.NotEqual(0, product2.ProductID);

            product1 = await _client
                .For<Product>()
                .Filter(x => x.ProductName == "Test1")
                .FindEntryAsync();
            Assert.NotNull(product1);
            product2 = await _client
                .For<Product>()
                .Filter(x => x.ProductName == "Test2")
                .FindEntryAsync();
            Assert.NotNull(product2);
        }
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:30,代码来源:BatchTypedTests.cs

示例4: PartialFailures

 public async Task PartialFailures()
 {
     var batch = new ODataBatch(_serviceUri);
     batch += c => c.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m } }, false);
     batch += c => c.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 10m }, { "SupplierID", 0xFFFF } }, false);
     await AssertThrowsAsync<WebRequestException>(async () => await batch.ExecuteAsync());
 }
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:7,代码来源:BatchTests.cs

示例5: ReadOnlyBatch

        public async Task ReadOnlyBatch()
        {
            IDictionary<string, object> product = null;
            var batch = new ODataBatch(_serviceUri);
            batch += async c => product = await c.FindEntryAsync("Products");
            await batch.ExecuteAsync();

            Assert.NotNull(product);
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:9,代码来源:BatchTests.cs

示例6: AsyncWithAllFailures

 public async Task AsyncWithAllFailures()
 {
     using (var batch = new ODataBatch(_serviceUri))
     {
         var client = new ODataClient(batch);
         await client.InsertEntryAsync("Products", new Entry() { { "UnitPrice", 10m } }, false);
         await client.InsertEntryAsync("Products", new Entry() { { "UnitPrice", 20m } }, false);
         Assert.Throws<WebRequestException>(() => batch.Complete());
     }
 }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:10,代码来源:BatchTests.cs

示例7: AsyncWithPartialFailures

 public async Task AsyncWithPartialFailures()
 {
     using (var batch = new ODataBatch(_serviceUri))
     {
         var client = new ODataClient(batch);
         await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m } }, false);
         await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 10m }, { "SupplierID", 0xFFFF } }, false);
         Assert.Throws<WebRequestException>(() => batch.Complete());
     }
 }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:10,代码来源:BatchTests.cs

示例8: Success

        public async Task Success()
        {
            var batch = new ODataBatch(_serviceUri);
            batch += x => x.InsertEntryAsync("Products", CreateProduct(5001, "Test1"), false);
            batch += x => x.InsertEntryAsync("Products", CreateProduct(5002, "Test2"), false);
            await batch.ExecuteAsync();

            var product = await _client.FindEntryAsync("Products?$filter=Name eq 'Test1'");
            Assert.NotNull(product);
            product = await _client.FindEntryAsync("Products?$filter=Name eq 'Test2'");
            Assert.NotNull(product);
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:12,代码来源:BatchODataTests.cs

示例9: Success

        public async Task Success()
        {
            var batch = new ODataBatch(_serviceUri);
            batch += c => c.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m } }, false);
            batch += c => c.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 20m } }, false);
            await batch.ExecuteAsync();

            var product = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test1'");
            Assert.NotNull(product);
            product = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test2'");
            Assert.NotNull(product);
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:12,代码来源:BatchTests.cs

示例10: InsertUpdateDeleteSingleBatch

        public async Task InsertUpdateDeleteSingleBatch()
        {
            var key = new Entry() { { "Name", "Test11" } };

            var batch = new ODataBatch(_serviceUri);
            batch += x => x.InsertEntryAsync("Products", CreateProduct(5011, "Test11"), false);
            batch += x => x.UpdateEntriesAsync("Products", "Products?$filter=Name eq 'Test11'", new Entry() { { "Price", 22m } });
            batch += x => x.DeleteEntriesAsync("Products", "Products?$filter=Name eq 'Test11'");
            await batch.ExecuteAsync();

            var product = await _client.FindEntryAsync("Products?$filter=Name eq 'Test11'");
            Assert.Equal(18d, Convert.ToDouble(product["Price"]));
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:13,代码来源:BatchODataTests.cs

示例11: PartialFailures

 public async Task PartialFailures()
 {
     var batch = new ODataBatch(_serviceUri);
     batch += c => c
         .For<Product>()
         .Set(new { ProductName = "Test1", UnitPrice = 10m })
         .InsertEntryAsync(false);
     batch += c => c
         .For<Product>()
         .Set(new { ProductName = "Test2", UnitPrice = 20m, SupplierID = 0xFFFF })
         .InsertEntryAsync(false);
     await AssertThrowsAsync<WebRequestException>(async () => await batch.ExecuteAsync());
 }
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:13,代码来源:BatchTypedTests.cs

示例12: PartialFailures

 public async Task PartialFailures()
 {
     var x = ODataDynamic.Expression;
     var batch = new ODataBatch(_serviceUri);
     batch += c => c
         .For(x.Products)
         .Set(x.ProductName = "Test1", x.UnitPrice = 10m)
         .InsertEntryAsync(false);
     batch += c => c
         .For<Product>()
         .Set(x.ProductName = "Test2", x.UnitPrice = 20m, x.SupplierID = 0xFFFF)
         .InsertEntryAsync(false);
     await AssertThrowsAsync<WebRequestException>(async () => await batch.ExecuteAsync());
 }
开发者ID:rexwhitten,项目名称:Simple.OData.Client,代码行数:14,代码来源:BatchDynamicTests.cs

示例13: AsyncWithSuccess

        public async Task AsyncWithSuccess()
        {
            using (var batch = new ODataBatch(_serviceUri))
            {
                var client = new ODataClient(batch);
                await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m } }, false);
                await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 20m } }, false);
                batch.Complete();
            }

            var product = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test1'");
            Assert.NotNull(product);
            product = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test2'");
            Assert.NotNull(product);
        }
开发者ID:rmagruder,项目名称:Simple.OData.Client,代码行数:15,代码来源:BatchTests.cs

示例14: SuccessWithResults

        public async Task SuccessWithResults()
        {
            IDictionary<string, object> product1 = null;
            IDictionary<string, object> product2 = null;

            var batch = new ODataBatch(_serviceUri);
            batch += async x => { product1 = await x.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test1" }, { "UnitPrice", 10m }}); };
            batch += async x => { product2 = await x.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 20m }}); }; 
            await batch.ExecuteAsync();

            Assert.NotNull(product1["ProductID"]);
            Assert.NotNull(product2["ProductID"]);

            product1 = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test1'");
            Assert.NotNull(product1);
            product2 = await _client.FindEntryAsync("Products?$filter=ProductName eq 'Test2'");
            Assert.NotNull(product2);
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:18,代码来源:BatchTests.cs

示例15: PartialFailures

        public async Task PartialFailures()
        {
            var batch = new ODataBatch(_serviceUri);
            batch += c => c
                .For<Product>()
                .Set(new { ProductName = "Test1", UnitPrice = 10m })
                .InsertEntryAsync(false);
            batch += c => c
                .For<Product>()
                .Set(new { ProductName = "Test2", UnitPrice = 20m, SupplierID = 0xFFFF })
                .InsertEntryAsync(false);

            try
            {
                await batch.ExecuteAsync();
            }
            catch (WebRequestException exception)
            {
                Assert.NotNull(exception.Response);
            }
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:21,代码来源:BatchTypedTests.cs


注:本文中的ODataBatch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。