LINQ in C#

Hi, I am attempting to replace the database in an application with MariaDB. This application is written in C# and previously accessed the database (mostly inserts) with LINQ. When I attempt to insert (other transactions have the same type of issue) I get the error message:

"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 '[t0].[Id], [t0].[BirthYear], [t0].[FirstName], [t0].[Gender], [t0].[LastName], [' at line 1"

The table in MariaDB is setup the same as it was in MS SQL.

Any thoughts on this subject would be most appreciated. I could go back and remove all use of LINQ and write SQL by hand (which is how I would have implemented it in the first place due to LINQ being the bane of my existence), but if I can get it to work as is it will save a great deal of time, and therefore money.

Thanks, Jeremy

Answer

This generated SQL uses MSSQL style for quoting identifiers (square brackets). In MariaDB you can quote identifiers either with backticks (`t0`.`id` — MySQL style) or with double quotes ("t0"."id" — SQL standard syntax, requires sql_mode=ANSI_QUOTES).

See if you can configure LINQ to quite identifiers appropriately.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.