我的新项目结构存在问题。 我在另一个项目中排除了Models文件夹,并添加了对现有Nhibernate项目的引用。这是我的设置:
KUNDEN.cs:
namespace webportale_ger_webservice.Model
{
public class KUNDEN
{
public KUNDEN() { }
public virtual int AR { get; set; }
public virtual STRASSE STRASSE { get; set; }
public virtual BLZ BLZ { get; set; }
public virtual KST KST { get; set; }
public virtual KTRAEGER KTRAEGER { get; set; }
public virtual double? KNUMMER { get; set; }
}}
KUNDEN.hbm.xml:
<hibernate-mapping namespace="webportale_ger_webservice.Model" xmlns="urn:nhibernate-mapping-2.2"> <class name="KUNDEN" table="KUNDEN" lazy="false" >
<id name="AR" column="AR"><generator class="webportale_ger_webservice.Routinen.NextKey,webportale ger webservice" /></id>
<many-to-one name="STRASSE">
<column name="ARSTRASSE" not-null="false" />
</many-to-one>
<many-to-one name="BLZ">
<column name="ARBLZ" not-null="false" />
</many-to-one>
<many-to-one name="KST">
<column name="ARKSTREF" not-null="false" />
</many-to-one>
<many-to-one name="KTRAEGER">
<column name="arktraeger_k" not-null="false" />
</many-to-one>
<property name="KNUMMER">
<column name="KNUMMER" sql-type="numeric" not-null="false" />
</property> </class></hibernate-mapping>
可以编译,但只要我想用nhibernate(选择KUNDE)做一些事情我就会收到以下错误:
NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: KUNDEN is not mapped [from KUNDEN where ar=54780]
bei NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.RequireClassPersister(String name)
bei NHibernate.Hql.Ast.ANTLR.Tree.FromElementFactory.AddFromElement()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElement()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElementList()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromClause()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement()
bei NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()
bei NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary2 replacements, Boolean shallow, String collectionRole)
bei NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
bei NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary2 enabledFilters)
bei NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
bei NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString)
bei webportale_ger_webservice.web_api.Stamm_SELECT_Kunde() in C:\Quellen\VSWebNeoBackEnd\VSWebNeoBackEnd\VSWebNeoBackEnd\project india webservice\webportale_ger_webservice.asmx.cs:Zeile 664.
所有映射文件都标记为嵌入式资源。 我假设它与命名空间或程序集有关。 我的配置:
static NHibernateHelper()
{
configuration.Configure();
configuration.AddAssembly("VSWebNeoBackEndModel");
sessionFactory = configuration.BuildSessionFactory();
}
web.config:
<hibernate-configuration>
<session-factory>...
<mapping assembly="VSWebNeoBackEndModel" />
... </session-factory>
</hibernate-configuration>
models-project的程序集名称为:VSWebNeoBackEndModel
models-project的命名空间是:webportale_ger_webservice
mapping / nhibernate项目的程序集名称为:webportale ger webservice
mapping / nhibernate项目的命名空间是:webportale_ger_webservice
在排除另一个项目中的模型之前,一切正常。我错了什么?
答案 0 :(得分:0)