Dapper Contrib插入MySQL语法错误

时间:2016-04-22 09:11:05

标签: dapper dapper-extensions micro-orm

嘿,我使用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!");
            }
        }

如何解决这个问题?在此先感谢

1 个答案:

答案 0 :(得分:0)

你又来了:) 班级Cause是否有Table("tbl_cause")指令? 阅读dapper contrib extensions文档here