AutoQuery: inserting Chinese characters?

Is there anything special I have to do to handle Russian or Chinese characters when inserting/updating strings using AutoQuery into a MSSQL 2022 database?

In SQL, for example, I would prefix the Russian/Chinese strings with N to indicate Unicode:

UPDATE Document
SET FileName1 = N'кофе'
   ,FileName2 = N'屏幕截图 2024'
WHERE Id = 'B6523615-C013-F111-B3CC-C86E0851C5FD'

The columns are defined as NVARCHAR, with Latin1_General_CI_AS collation.

When I perform an update or create using AutoQuery, the characters become ‘?’ in the db column.

Any suggestions?

You would need to configure your SqlServer dialect to UseUnicode, e.g:

services.AddOrmLite(options => options.UseSqlServer(connString, dialect =>
{
    dialect.GetStringConverter().UseUnicode = true;
}));

Great, thank you, that worked.

1 Like