【问题标题】:Dapper Contrib Insert MySQL Syntax ErrorDapper Contrib 插入 MySQL 语法错误
【发布时间】:2016-04-22 09:11:05
【问题描述】:

嘿,我在使用 Dapper.Contrib 的 MySQL 中遇到语法错误

MySQL server version for the right syntax to use near '[cause_code],[cause_name]) values ('000-DDH', 'No Money')' at line 1

在mysql中插入的正确语法是

"Insert Into `tbl_cause` (`cause_code`, `cause_name`) VALUES('blah', 'blah')"; 

我的代码:

var entity = new Cause { cause_code = "000-DDH", cause_name = "No Money" };
        using (IDbConnection cn = ConStr.Conn()) 
        {
            long ins = cn.Insert(entity);
            if (ins > 0)
            {
                MessageBox.Show("Cause Code: " + entity.cause_code + " Successfully Added!");
                GDRD();
            }
            else {
                MessageBox.Show("Cause Code: " + entity.cause_code + " While trying to Add an Error Occurred!");
            }
        }

如何解决这个问题?提前致谢

【问题讨论】:

    标签: dapper dapper-extensions micro-orm


    【解决方案1】:

    又是你 :) Cause 类是否有 Table("tbl_cause") 指令? 阅读 dapper contrib 扩展文档here

    【讨论】:

      猜你喜欢
      • 2019-03-31
      • 1970-01-01
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-13
      相关资源
      最近更新 更多