在 Fluent NHibernate 中映射人员和员工
如何使用 Fluent NHibernate(实体、映射类等)映射以下查询,员工 ID 存储在标识符表中。人员表包含员工信息和非员工信息。
SELECT p.Id、p.FirstName、p.LastName
FROM Person p
UNION ALL
SELECT e.Id, e.FirstName, e.LastName
FROM Employee e
INNER JOIN 标识符 i on (e.Id = i.value)
INNER JOIN 类型 t on (i.typeid = t.id and i.typeName = 'EmployeeId')
有人吗?
How can I map following queries using Fluent NHibernate (entity, mapping class etc..), the employee ids are stored in identifier tables. Person table contains employee information and non-employee information.
SELECT p.Id, p.FirstName, p.LastName
FROM Person p
UNION ALL
SELECT e.Id, e.FirstName, e.LastName
FROM Employee e
INNER JOIN identifier i on (e.Id = i.value)
INNER JOIN type t on (i.typeid = t.id and i.typeName = 'EmployeeId')
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用联合策略来映射您的子类。阅读 Fluent NHibernate wiki 的 子类化 部分,而不是调用
您可以在
。ClassMap
中调用UseUnionSubclassForInheritanceMapping
中的 DiscrimminateSubclassesOnColumn您最终会得到一个基类的
ClassMap
,然后是每个子类的SubclassMap
;ClassMap
将在其构造函数中调用UseUnionSubclassForInheritanceMapping
。像这样的东西:
You need to use a union strategy for mapping your subclasses. Have a read of the subclassing section of the Fluent NHibernate wiki, but instead of calling
DiscriminateSubclassesOnColumn
in yourClassMap
you'd callUseUnionSubclassForInheritanceMapping
.What you'd end up with is a
ClassMap
for your base-class, then aSubclassMap
for each of your subclasses; theClassMap
would have a call toUseUnionSubclassForInheritanceMapping
in it's constructor.Something like this: