本文整理汇总了C#中DataServiceContext.TryGetUri方法的典型用法代码示例。如果您正苦于以下问题:C# DataServiceContext.TryGetUri方法的具体用法?C# DataServiceContext.TryGetUri怎么用?C# DataServiceContext.TryGetUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataServiceContext
的用法示例。
在下文中一共展示了DataServiceContext.TryGetUri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSpecialCharactersInPrimaryKey
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);
}
示例2: TestLongTypeAsPrimaryKey
public async Task TestLongTypeAsPrimaryKey()
{
var client = new DataServiceContext(new Uri(this.BaseAddress));
client.Format.UseJson(GetEdmModel());
var query = client.CreateQuery<LongPrimaryKeyType>("LongPrimaryKeyType");
var models = await query.ExecuteAsync();
foreach (var model in models)
{
Uri selfLink;
Assert.True(client.TryGetUri(model, out selfLink));
Console.WriteLine(selfLink);
client.UpdateObject(model);
var response = await client.SaveChangesAsync();
Assert.Equal(200, response.Single().StatusCode);
}
}
示例3: TestLongTypeAsPrimaryKey
public void TestLongTypeAsPrimaryKey()
{
DataServiceContext ctx = new DataServiceContext(new Uri(this.BaseAddress));
var models = ctx.CreateQuery<LongPrimaryKeyType>("LongPrimaryKeyType").ToList();
foreach (var model in models)
{
Uri selfLink;
Assert.True(ctx.TryGetUri(model, out selfLink));
Console.WriteLine(selfLink);
ctx.UpdateObject(model);
var response = ctx.SaveChanges().Single();
Assert.Equal(200, response.StatusCode);
}
}