这是我的流利类图:
class ImportedAccountsMap : ClassMap<ImportedAccounts>
{
public ImportedAccountsMap()
{
Id(x => x.Id);
Map(x => x.Acct_FName);
Map(x => x.Acct_LName);
Map(x => x.Acct_Phone1);
Map(x => x.Acct_Email);
Map(x => x.Date);
Map(x => x.Exists);
Map(x => x.Deleted);
}
}
我的控制器代码
public void ImportInsertTest()
{
using (ISession session = MvcApplication.SessionFactory.OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
ImportedAccounts ia = new ImportedAccounts();
ia.Date = "test";
ia.Deleted = false;
ia.Exists = false;
ia.Acct_FName = "test";
ia.Acct_LName = "test";
ia.Acct_Email = "test@test.com";
session.Save(ia);
tx.Commit();
}
}
}
我收到此错误:
{"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Exists, Deleted) VALUES ('test', 'test', 'test', 'test@test.com', 'test', 0, 0)' at line 1"}
答案 0 :(得分:1)
当我的实体属性名称等于所使用的数据库方言的关键字时,我得到了类似的错误。我不知道MySQL的方言,但属性存在或/和删除可能会导致问题。
重命名您的属性或重命名列,如:
Map(x => x.Deleted).Column("IsDeleted");
如果您无法选择此选项,则还可以启用关键字引用。请参阅此link。