NHIbernate:将实体中的多行映射到单个对象表示
假设我有以下架构:
表:显示 显示 ID 电影ID 剧院_id 显示日期 show_time
表:电影 电影ID 标题 ...
表:剧院 剧院_id 姓名 ...
是否可以创建一个 NHibernate 映射来生成以下对象层次结构?
剧院 - 电影 -- 放映列表,其中每个放映包含 - 日期 -- 时间(以逗号分隔的日期时间字符串)
一些示例数据:
showing_id movie_id theater_id show_date show_time
-------------------------------------------------------------------------
1 1 1 2010-12-23 13:25
2 1 1 2010-12-23 15:25
3 1 1 2010-12-23 17:25
4 1 1 2010-12-23 19:25
5 1 1 2010-12-24 12:00
6 1 1 2010-12-24 14:45
对于电影 ID 1,我希望将其映射到显示对象列表,其中包含: 显示 1:日期 = 2010-12-23,放映时间:13:25、15:25、17:25、19:25 显示 2:日期 = 2010-12-24,放映时间:12:00、14:45
我假设我需要使用标准 NHibernate 映射约定设置映射,然后将原始数据调整到我正在查找的结构中为了。我想我应该仔细检查一下,确保没有遗漏什么。
谢谢!
Suppose I have the following schema:
Table: Showing
showing_id
movie_id
theater_id
show_date
show_time
Table: Movie
movie_id
title
...
Table: Theater
theater_id
name
...
Is it possible to create a NHibernate mapping that would result in the following object hierarchy?
Theater
- Movie
-- List of Showings where each showing consists of
-- Date
-- Times (comma delimited string of times for the date)
Some sample data:
showing_id movie_id theater_id show_date show_time
-------------------------------------------------------------------------
1 1 1 2010-12-23 13:25
2 1 1 2010-12-23 15:25
3 1 1 2010-12-23 17:25
4 1 1 2010-12-23 19:25
5 1 1 2010-12-24 12:00
6 1 1 2010-12-24 14:45
For movie ID 1, I'd like this to map to a list of showing objects consisting of:
Showing 1: Date = 2010-12-23, Showtimes: 13:25, 15:25, 17:25, 19:25
Showing 2: Date = 2010-12-24, Showtimes: 12:00, 14:45
I'm assuming that I need to set the mappings using the standard NHibernate mapping conventions and then massage the raw data into the structure I'm looking for. I figured I'd double check and make sure there wasn't something I was missing out on.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点像。我会用额外的数据(显示)来建立多对多的关系模型。这被建模为两个一对多关系。这些课程将是:
Sort of. I would model this a many-to-many relationship with extra data (the showing). This is modeled as two one-to-many relationships. The classes would be: