NHibernate 配置问题

修改一下昵称 2009-10-15 10:26:08
错误提示:System.InvalidOperationException: Could not find the dialect in the configuration

在网上查了N久资料,好像是版本错误。

但是我都核对了,应该没错啊。

NHibernate.dll 2.0的版的

User.hbm.xml配置文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHbe.entity.User, entity.User" table="users">
<id name="Id" column="LogonId" type="String" length="20">
<generator class="assigned" />
</id>
<property name="UserName" column="Name" type="String" length="40"/>
<property name="Password" type="String" length="20"/>
<property name="EmailAddress" type="String" length="40"/>
<property name="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>


web.config 配置文件

<configSections>
<section name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>

<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"/>
<add
key="hibernate.connection.connection_string"
value="server=.\DB05;uid=sa;pwd=123456;database=MyDB"/>
</nhibernate>




...全文
56 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
修改一下昵称 2009-10-16
  • 打赏
  • 举报
回复
解决。结贴
wuyq11 2009-10-15
  • 打赏
  • 举报
回复
0
0 少了dialect属性设置
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory >
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string"></property>
<mapping assembly="Entity" />
</session-factory>
</hibernate-configuration>
参考
修改一下昵称 2009-10-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xray2005 的回复:]
XML code<xmlversion="1.0" encoding="utf-8" ?><configuration><configSections><sectionname="nhibernate" type="System.Configuration.NameValueSectionHandler"/> configSections><nhibernate><addkey="hib¡­
[/Quote]

按照你这样配置还是报那错误
xray2005 2009-10-15
  • 打赏
  • 举报
回复

<xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler" /> configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" /> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" /> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" /> <add key="hibernate.connection.connection_string" value="Server=localhost;uid=sa;password=sa;database=NHTrial" /> </nhibernate><configuration>然后,我们在程序中只需简单的初始化Configuration对象即可。

Configuration cfg = new Configuration();

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧