Search code examples
c#mysqlmariadbdapperdapper-fastcrud

create query for mysql in Dapper FastCRUD


I want to use dapper fastcrud(DLL FOR CRUD Operation in dapper) with mariadb(mysql engine) but when i want to execute my code I have syntax Error

It seems when fastcrud wants to create query ,it's default behaviour is creating query appropriate for sqlserver(for example using [] ) and i want to change this behaviour to create query mysql something like sqldialetic

I would appreciate if anybody can help me

my sample code:

var TrustedZone = db.Get(new TrustedZone { Id = 1 });

Error:

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: You have an error in your SQL syntax; 
check the manual that corresponds to your MariaDB server version 
for the right syntax to use near 
'[Id],[IP],[Title],[Description] FROM [TrustedZones] WHERE [Id]=1' at line 1

Solution

  • At the beginning of your program, configure Dapper.FastCRUD as follows:

    OrmConfiguration.DefaultDialect = SqlDialect.MySql;