根据字典更新生成SQL语句问题 返回

SqlSugar
6 119
该叫什么 .. 发布于1周前
悬赏:5 飞吻
//字典集合
var dtList = new List<Dictionary<stringobject>>();
dtList.Add(dt);
dtList.Add(dt2);
var t666 = db.Updateable(dtList).AS("student").WhereColumns("id").ExecuteCommand();


生成SQL:

UPDATE  dictionary`2 S    INNER JOIN             (
              
 SELECT N'título pronta' AS `popover_title`,N'Título de solicitud' AS `popover_description`,N'1' AS `id`        
UNION ALL
 SELECT N'prompt title' AS `popover_title`,N'Application title' AS `popover_description`,N'2' AS `id`        
UNION ALL
 SELECT N'标题' AS `popover_title`,N'内容' AS `popover_description`,N'3' AS `id`
            ) T ON S.`id`=T.`id`
                   SET S.`popover_title`=T.`popover_title`,S.`popover_description`=T.`popover_description` ;


其中表名部分没有替换成功


热忱回答6

  • sqlsugar版本号是多少, dbtype什么

    0 回复
  • .. .. VIP0
    1周前

    @fate stay night:sqlsugar版本是5.0.4,DB是Mysql

    0 回复
  •             var dtList = new List<Dictionary<string, object>>();
                var dt1 = new Dictionary<string, object>();
                dt1.Add("id", 1);
                dt1.Add("name","a");
                var dt2 = new Dictionary<string, object>();
                dt2.Add("id", 2);
                dt2.Add("name", "a2");
                dtList.Add(dt1);
                dtList.Add(dt2);
                var t666 = db.Updateable(dtList).AS("student").WhereColumns("id").ExecuteCommand();

    我这边生成的SQL OK

    0 回复
  • UPDATE  `student` S    INNER JOIN             (
    
     SELECT N'1' AS `id`,N'a' AS `name`
    UNION ALL
     SELECT N'2' AS `id`,N'a2' AS `name`
    
    
                ) T ON S.`id`=T.`id`
                       SET S.`name`=T.`name` ;


    0 回复
  • 你可以写个控制台用例测试一下

    0 回复
  • .. .. VIP0
    1周前

    @fate stay night:好的,非常谢谢,我试试

    0 回复