问题描述
我正在流畅地使用Nhibernate.现在,我想调用一些存储过程并使用命名查询.我创建了一些xml:
I am using Nhibernate with fluent.Now I want to call some Stored procedure and use named Queries.I created some xml:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping>
<sql-query name="CleanAppendicesHierarchies">
exec intf_CleanUpAppendixHierarchy
</sql-query>
</hibernate-mapping>
FluentConfiguration cfg =
Fluently.Configure().Database(MsSqlConfiguration.MsSql2005.ConnectionString(
c => c.Is(dbConnectionString)).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssembly(mappingAssembly))
.Mappings(m => m.HbmMappings.AddFromAssembly(mappingAssembly));
现在我总是得到异常:(最内部的异常){未期望hibernate-mapping xmlns ="."} {"XML文档(1、2)中存在错误."}
Now I got always the Exception:(most inner exception){"hibernate-mapping xmlns='' was not expected."} {"There is an error in XML document (1, 2)."}
我无所事事,但是如果我删除休眠映射,那么它将抱怨sql-query标记.
I fiddled around but if I remove hibernate-mapping then it complains about the sql-query tag.
我的方法有什么问题?我用谷歌搜索已经找到的例子,但是当然没有Fluent....
What is wrong in my approach? I googled already found examples but of course with out Fluent....
任何提示都值得赞赏
推荐答案
奇怪,我可以解决这个问题:
Strange, I got it working with that:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="FactsheetsDataLayer"
namespace="FactsheetsDataLayer">
<sql-query name="CleanAppendicesHierarchies">
exec intf_CleanUpAppendixHierarchy
</sql-query>
</hibernate-mapping>
然后我将XMl命名为:POCOClassName.hbm.xml
Then I named the XMl like: POCOClassName.hbm.xml
我不知道有什么帮助,但现在可以了....
I do not know what helped but now it worked....
这篇关于NHibernate流利并命名查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!