gpt4 book ai didi

c# - Azure 移动服务 InsertAsync 获取状态

转载 作者:行者123 更新时间:2023-12-03 03:14:23 29 4
gpt4 key购买 nike

我正在插入我的 Azure 移动服务 SQL 数据库,它工作正常,但我想知道是否存在错误,以便我可以更正它。

如何从 InsertAsync 获取状态以查看它是成功还是失败?

public static MobileServiceClient MobileService = new MobileServiceClient(
"https://YOUR-DOMAIN.azure-mobile.net/",
"YOUR-KEY"
);

static IMobileServiceTable<Product> productTable = MobileService.GetTable<Product>();

Product product = new Product {
name = NPDName.Text,
description = NPDDescription.Text,
price = NPDPriceExkl.Text,
tax = NPDTax.Text,
stock = NPDStock.Text,
available = NPDCBAvailable.Checked,
active = true
};

productTable.InsertAsync(product);

最佳答案

How do i get the status from the InsertAsync to see if it succeed or failed?

InsertAsync返回一个任务。如果你想知道它的状态,你需要await它。如果失败,则会传播异常:

public async Task InsertAsync()
{
Product product = new Product
{
name = NPDName.Text,
description = NPDDescription.Text,
price = NPDPriceExkl.Text,
tax = NPDTax.Text,
stock = NPDStock.Text,
available = NPDCBAvailable.Checked,
active = true
};

await productTable.InsertAsync(product);
}

关于c# - Azure 移动服务 InsertAsync 获取状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30692495/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com