本文整理汇总了C#中ODataBatch类的典型用法代码示例。如果您正苦于以下问题:C# ODataBatch类的具体用法?C# ODataBatch怎么用?C# ODataBatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataBatch类属于命名空间,在下文中一共展示了ODataBatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: InsertSingleEntityWithMultipleAssociationsSingleBatch
public async Task InsertSingleEntityWithMultipleAssociationsSingleBatch()
{
var product1 = new Product() {ProductName = "Test15", UnitPrice = 21m};
var product2 = new Product() {ProductName = "Test16", UnitPrice = 22m};
var batch = new ODataBatch(_serviceUri);
batch += c => c
.For<Product>()
.Set(product1)
.InsertEntryAsync(false);
batch += c => c
.For<Product>()
.Set(product2)
.InsertEntryAsync(false);
batch += async c => await c
.For<Category>()
.Set(new { CategoryName = "Test17", Products = new[] { product1, product2 } })
.InsertEntryAsync(false);
await batch.ExecuteAsync();
var category = await _client
.For<Category>()
.Expand(x => x.Products)
.Filter(x => x.CategoryName == "Test17")
.FindEntryAsync();
Assert.Equal(2, category.Products.Count());
}
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:27,代码来源:BatchTypedTests.cs
示例17: InsertSingleEntityWithSingleAssociationSingleBatch
public async Task InsertSingleEntityWithSingleAssociationSingleBatch()
{
var category = new Category() { CategoryName = "Test13" };
var batch = new ODataBatch(_serviceUri);
batch += async c => await c
.For<Category>()
.Set(category)
.InsertEntryAsync();
batch += c => c
.For<Product>()
.Set(new { ProductName = "Test14", UnitPrice = 21m, Category = category })
.InsertEntryAsync();
await batch.ExecuteAsync();
var product = await _client
.For<Product>()
.Expand(x => x.Category)
.Filter(x => x.ProductName == "Test14")
.FindEntryAsync();
Assert.Equal("Test13", product.Category.CategoryName);
}
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:21,代码来源:BatchTypedTests.cs
示例18: InsertUpdateDeleteSeparateBatches
public async Task InsertUpdateDeleteSeparateBatches()
{
var batch = new ODataBatch(_serviceUri);
batch += c => c
.For<Product>()
.Set(new { ProductName = "Test12", UnitPrice = 21m })
.InsertEntryAsync(false);
await batch.ExecuteAsync();
var product = await _client
.For<Product>()
.Filter(x => x.ProductName == "Test12")
.FindEntryAsync();
Assert.Equal(21m, product.UnitPrice);
var productID = product.ProductID;
batch = new ODataBatch(_serviceUri);
batch += c => c
.For<Product>()
.Key(productID)
.Set(new { UnitPrice = 22m })
.UpdateEntryAsync(false);
await batch.ExecuteAsync();
product = await _client
.For<Product>()
.Filter(x => x.ProductName == "Test12")
.FindEntryAsync();
Assert.Equal(22m, product.UnitPrice);
batch = new ODataBatch(_serviceUri);
batch += c => c
.For<Product>()
.Key(productID)
.DeleteEntryAsync();
await batch.ExecuteAsync();
product = await _client
.For<Product>()
.Filter(x => x.ProductName == "Test12")
.FindEntryAsync();
Assert.Null(product);
}
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:43,代码来源:BatchTypedTests.cs
示例19: Batch
public async Task Batch()
{
IEnumerable<Airline> airlines1 = null;
IEnumerable<Airline> airlines2 = null;
var batch = new ODataBatch(_client);
batch += async c => airlines1 = await c
.For<Airline>()
.FindEntriesAsync();
batch += c => c
.For<Airline>()
.Set(new Airline() { AirlineCode = "TT", Name = "Test Airline" })
.InsertEntryAsync(false);
batch += async c => airlines2 = await c
.For<Airline>()
.FindEntriesAsync();
await batch.ExecuteAsync();
Assert.Equal(8, airlines1.Count());
Assert.Equal(8, airlines2.Count());
}
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:21,代码来源:TripPinTests.cs
示例20: GetInvolvedPeopleInBatch
public async Task GetInvolvedPeopleInBatch()
{
var batch = new ODataBatch(_client);
IEnumerable<object> people = null;
batch += async x =>
{
people = await x.For<Person>()
.Key("scottketchum")
.NavigateTo<Trip>()
.Key(0)
.Function("GetInvolvedPeople")
.ExecuteAsEnumerableAsync();
};
await batch.ExecuteAsync();
Assert.Equal(2, people.Count());
}
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:18,代码来源:TripPinTests.cs
注:本文中的ODataBatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论