In .NET, strings are Unicode, however some databases have specific data types for strings which differentiate between ASCII and Unicode (e.g. in MS SQL Server
If the database makes the distinction and the wrong type is used in a SQL command, it can result in poor performing queries (table scans over index lookups or unnecessary type conversion).
In MicroLite 5.0, the database connection/command handling has been exposed via a ‘database driver’. The new
IDbDriver interface defines a
HandleStringsAsUnicode property which is set to
true by default but allows explicit control over whether strings are sent to the database as ASCII or Unicode (the default).
If you use MS SQL Server and the columns are NVarChar, HandleStringsAsUnicode should be left as true (the default value). If they are VarChar, HandleStringsAsUnicode should be set to false.
For other databases, refer to the documentation and if in doubt, leave it set to true.
If you need to, you can set
false when the session factory is created:
var sessionFactory = Configure.Fluently() .ForMsSqlConnection("Connection") .CreateSessionFacory(); // Only change this if you are sure you need to. sessionFactory.DbDriver.HandleStringsAsUnicode = false;