2

嗨,我在 JSON 结构中的数据是这样的

{
  "Imei": 356980051541947,
  "sendIds": [
    {
      "Id": 13014
    },
    {
      "Id": 13190
    },
    {
      "Id": 13419
    },
    {
      "Id": 13422
    }
  ],
  "ApplicationVersion": 68,
  "GoogleId": "asdsadazxcjkh218",
  "ImagesVersion": "123:1"
}

我的课是:

public class PostData
{
    public int ApplicationVersion;
    public long Imei;
    public string GoogleId;
    public string FromDate;
    public string ToDate;
    public string ImagesVersion;
    public ItemId[] SendIds;
}

public class ItemId
{
    public int Id;
}

C# 代码简洁更新:

const string sql = "UPDATE dbo.SentMessage SET IsDelivered=1 WHERE SendID=@Id";
dapperConn.Execute(sql, postData.SendIds);

但是执行时出现如下错误

必须声明标量变量 \"@Id\

请帮我。

4

1 回答 1

2

发生此异常是因为您的类中的变量 isField和 not Property。因此,您必须将其更改为如下代码的属性:

public class PostData
{
    public int ApplicationVersion { get; set; };
    public long Imei { get; set; };
    public string GoogleId { get; set; };
    public string FromDate { get; set; };
    public string ToDate { get; set; };
    public string ImagesVersion { get; set; };
    public ItemId[] SendIds { get; set; };
}

public class ItemId
{
    public int Id { get; set; };
}
于 2016-12-08T06:13:16.333 回答