jchristn / DatabaseWrapper

Simple database wrapper for Microsoft SQL Server, MySQL, PostgreSQL, and Sqlite written in C# supporting dynamic query building and nesting using expressions.
MIT License
97 stars 26 forks source link

DatabaseWrapper: First draft of achieving independency from locales #20

Open Andrei-Errapart opened 9 months ago

Andrei-Errapart commented 9 months ago

Problem to be solved As present the DatabaseWrapper at least regarding MS Sql Server is dependent on the database on the SQL server having the same regional settings as DatabaseWrapper. The problem becomes worse when there are multiple databases with different locales.

Corresponding issue:

17

Solution The solution resolves the problem by using parametrized SQL queries. The amount of code is about the same as when sanitizing all the inputs.

Let me note that the reduction of lines of code in DatabaseWrapper.SqlServer was not due to conversion to use parametrized SQL queries.

As soon as the SQL query parametrization is OK for DatabaseWrapper.SqlServer, I will implement it for other drivers, too.

I am all ears for the improvements.

Andrei-Errapart commented 9 months ago
  1. I think removing the method TimeStamp and associated members was a mistake. I will put them back.
  2. In the case of Postgresql, the Npsql library has changed the handling of DateTimeOffsets in version 6.0: https://www.npgsql.org/doc/types/datetime.html. The Npsql only accepts DateTimeOffsets which have 0 for Offset.
Andrei-Errapart commented 9 months ago

At first sight it seems to work with RestDb.

jchristn commented 9 months ago

Hi @Andrei-Errapart sorry for the delay on getting back to you on this one, I will do my best to get to it ASAP. I appreciate your contribution!