是否可以通过windows azure获取插入表格的最新ID?
我的代码如下:
private IMobileServiceTable<FooToo> MyTable = App.MobileService.GetTable<FooToo>();
Foo new = new Foo();
await MyTable.InsertAsync(new);
在InsertAsync
之后我需要插入的元素的ID。怎么做?
答案 0 :(得分:2)
在您的情况下,new项将包含在InsertAsync行之后在服务器上获得的Id。
我使用的工作示例
//Creates an empty item (id is now null)
MyClass newItem = new MyClass();
//Uploading the item
await MobileService.GetTable<MyClass>().InsertAsync(newItem);
//Returning the id which is now the Id of the row on the server
return newItem.Id;