2
votes

We started to use .NET version of OrmLite in our C# project that uses SQL Server 2008 R2 Express storage. https://github.com/ServiceStack/ServiceStack.OrmLite

Now we discovered that it is not possible to save Unicode characters to the table by using this ORM mapper with SQL Server.

We need multilingual application (so setting specific LOCALE in SQL Server is not the solution).

We also tested that using plain ADO.NET all works fine!

We also tried to set configuration option:

OrmLiteConfig.DialectProvider.UseUnicode = true;

No changes at all!
(I think it's related only to table creation not string saving...)

2
What data type are you using in your database column where this string is being stored? - Sergey Rybalkin
In the source code I found, that there is not used parametrized Query parameters - string values are being concatenated to generate Create/Upate/Delete SQL statements! To solve this problem I moved to the Dapper ORM and did some modifications to suit my project needs. - janeks malinovskis
I had a similar problem with MySQL and OrmLite. Adding CharSet=utf8; to the end of the connection string got it working for me. Maybe there is a similar way to declare the charset for SQL Server in the connect string. - swax

2 Answers

1
votes

For people who are still experiencing this issue: in v3.9.71 of OrmLite this issue has been fixed if you set OrmLiteConfig.DialectProvider.UseUnicode = true;

This will change the underlying query to use Unicode.

1
votes

For .NET Core

You should put:

OrmLiteConnectionFactory dbFactory = new OrmLiteConnectionFactory(connStr, SqlServerDialect.Provider);

OrmLiteConfig.DialectProvider.GetStringConverter().UseUnicode = true;

into your Startup.cs