#region mysql
[Route("add2")]
[HttpPost]
public ContentResult add2([FromForm] body c)
{
//查询
var result = Model.Connect.Mysql.Query<body>().Where(a => a.key == c.key).FirstOrDefault();
string msg = "已经存在";
if (result == null)
{//添加
result = Model.Connect.Mysql.Insert<body>(c);
}
else
{
if (c.type == "update")
{//修改
int count = Model.Connect.Mysql.Update<body>(a => a.key == a.key, n => new body()
{
values = c.values,
time = c.time
});
}
}
string strJson = JsonConvert.SerializeObject(result);
return new ContentResult { Content = msg + strJson, ContentType = "application/json" };
}
#endregion
JAVA对标c# 操作sql java还有更简单的嘛?
最新推荐文章于 2024-08-22 22:51:37 发布