我正在插入我的Azure Mobileservice 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);
答案 0 :(得分:1)
如何从InsertAsync获取状态以查看它是成功还是失败?
InsertAsync
返回Task
。如果您想知道它的状态,您需要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);
}