Here is my fluent classmap:
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);
}
}
And my controller code
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();
}
}
}
I’m getting this error:
{"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"}
I got a similar error, when my entity property names were equal to keywords of the used database dialect. I don’t know the dialect of MySQL, but the property Exists or/and Deleted may cause the problem.
Rename your properties or rename the columns like:
If this is no option for you, there is also a way to turn on quoting for keywords. See this link.