如何使用 C# 中的映射属性定义 NHibernate sql 查询?
因此,对于我们正在开发的项目,我们使用业务实体本身的映射属性来映射整个域模型。我有一个有效的 sql 查询映射,我想使用映射属性来定义它,但我不知道如何执行此操作。任何帮助表示赞赏。
这是需要翻译的 xml 映射:
<sql-query name="Query1">
<return class="My.Class, My.Assembly">
<return-property name="Field1" column="Field1"/>
<return-property name="Field2" column="Field2"/>
<return-property name="Field3" column="Field3"/>
<return-property name="Field4" column="Field4"/>
<return-property name="Field5" column="Field5"/>
<return-property name="Field6" column="Field6"/>
<return-property name="Field7" column="Field7"/>
<return-property name="Field8" column="Field8"/>
<return-property name="Field9" column="Field9" />
</return>
select Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9 from dbo.udf_CUSTOM (:Param1, :Param2, :Param3)
</sql-query>
So for a project that we are working on we have our entire domain model mapped using mapping-attributes on the business entities themselves. I have a working sql-query mapping that I would like to define using the mapping-attributes but I am not sure how to do this. Any help is appreciated.
Here is the xml mapping that needs to be translated:
<sql-query name="Query1">
<return class="My.Class, My.Assembly">
<return-property name="Field1" column="Field1"/>
<return-property name="Field2" column="Field2"/>
<return-property name="Field3" column="Field3"/>
<return-property name="Field4" column="Field4"/>
<return-property name="Field5" column="Field5"/>
<return-property name="Field6" column="Field6"/>
<return-property name="Field7" column="Field7"/>
<return-property name="Field8" column="Field8"/>
<return-property name="Field9" column="Field9" />
</return>
select Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9 from dbo.udf_CUSTOM (:Param1, :Param2, :Param3)
</sql-query>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
nHibernate 映射属性不支持它。如果确实需要使用外部 XML 映射,则可以定义它们。
请考虑Fluent nhibernate。这是映射对象的更好方法。
It's not supported by nHibernate mapping attributes. You can define an external XML mapping if you really need to use them.
Please consider fluent nhibernate. It's an even better way to map your objects.