c# - 如何使用 MySQL 配置流畅的 nHibernate

标签 c# mysql nhibernate fluent-nhibernate autofac

我正在尝试将 nHibernate 配置为使用 MySql 数据库。我找到了 mssql 和 sqlite 的示例,但没有找到 mysql 的示例。 那么,我该如何更改它以使其使用 mysql:

Fluently.Configure().Database(
        MsSqlConfiguration.MsSql2005.ConnectionString(
            c => c.FromConnectionStringWithKey("ConnectionString")
        )
    )
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>())
    .BuildSessionFactory())

最佳答案

MsSqlConfiguration.MsSql2005 更改为 MySqlConfiguration.Standard,这是我为项目贡献的一件事。

例子:

Fluently.Configure().Database(
        MySqlConfiguration.Standard.ConnectionString(
            c => c.FromConnectionStringWithKey("ConnectionString")
        )
    )
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>())
    .BuildSessionFactory())

关于c# - 如何使用 MySQL 配置流畅的 nHibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/626339/

相关文章:

c# - 将 SQL 转换为 QueryOver 以使用 group bys 获取行数

c# - 在 CRM2011 插件中创建 OrganizationServiceProxy 以使用早期绑定(bind)

MySQL 显示每个团队的第四个最小值

php - 下拉列表为空

c# - 让 NHibernate 在中等信任的共享主机上工作

c# - NHibernate- 防止删除特定实体(即设为只读)

c# - 如何在 ajax.actionlink 中显示 »

c# - ADO.NET 和数据集中的丢失更新

c# - C#中的实时视频流

mysql - 在 Mysql 中选择具有数字范围的查询