c#类不能用于Azure

本文关键字:Azure 用于 不能 | 更新日期: 2023-09-27 18:16:16

我是windows azure世界的新手,我正试图将一个项目发送到SQL DB并通过特定的"usrID"跟踪它,然后希望更新它。

现在我也有一个类:

public class Item
{
    public int Id { get; set; }
    [JsonProperty(PropertyName = "url")]
    public string url { get; set; }
    [JsonProperty(PropertyName = "usrID")]
    public string usrID { get; set; }
    [JsonProperty(PropertyName = "complete")]
    public bool Complete { get; set; }
}

保存/插入数据:

    private void ButtonSave_Click(object sender, RoutedEventArgs e)
    {
        var todoItem = new Item { usrID = "helloworld", url = Input.Text };
        InsertTodoItem(todoItem);
    }

当我尝试更新时,我使用这个:

    private void btns_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        Item item;
        item = new Item();
        item.url = "hello";
        UpdateItem(item);
    }

*尝试这样做将不起作用。它也不能让我做Item Item = new Item();

更新功能为:

    private async void UpdateItem(Item item)
    {
        await todoTable.UpdateAsync(item);
        items.Remove(item);
    }

所以,我要做的是,最后一个/唯一一个由"usrID"插入的项目,以获得该数据并显示它。但是,如果有什么变化,我希望从"usrID"中包含url的特定插入被更新(而不是完全删除)。

任何帮助将是伟大的!

c#类不能用于Azure

List<Item> items = await App.MobileService.GetTable<Item>().OrderBy(item => item.usrID).ToListAsync();
int mas = items.Count();
await Table.UpdateAsync(new Item {Id = mas, usrID = "helloworld", url = "itworked" });