2

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...)

Gray
  • 115,027
  • 24
  • 293
  • 354
Janeks Malinovskis
  • 511
  • 1
  • 5
  • 8
  • What data type are you using in your database column where this string is being stored? – Sergey Rybalkin Jun 01 '12 at 15:17
  • 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 Oct 10 '12 at 08:50
  • 1
    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. – MushroomSoda Nov 28 '12 at 07:54

2 Answers2

1

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.

Stef Leurs
  • 11
  • 1
1

For .NET Core

You should put:

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

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

into your Startup.cs