数据库
首页 > 数据库> > mysql – 如何在流畅的NHibernate中设置编码?

mysql – 如何在流畅的NHibernate中设置编码?

作者:互联网

我通过这个SQL查询创建了我的数据库:
  (“CREATE DATABASE”DBName“DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci”,连接)

我有这个流畅的配置:

Fluently.Configure()
                     .Database(MySQLConfiguration.Standard.ConnectionString(c => c.Server(server)
                        .Database(DBName).Username(username).Password(password)))
                     .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
                     .BuildSessionFactory();

如何在此配置中设置NHibernate编码?或者如何设置映射编码?

我想要这个,因为当我想选择具有UTF8编码的属性时,NHibernate sql将包括???????在带编码的字符串中

解决方法:

var mysqlconf = MySQLConfiguration.Standard
.ConnectionString(c => c.Is("Server=srv;Database=db;User=dev;Password=pass;CharSet=utf8"));

return Fluently.Configure().Database(mysqlconf).Mappings(m =>
    m.FluentMappings.AddFromAssemblyOf<Program>()).BuildSessionFactory();

标签:mysql,character-encoding,nhibernate,fluent-nhibernate
来源: https://codeday.me/bug/20190826/1734742.html