Groups
Groups
Sign in
Groups
Groups
NBear Google Group
Conversations
About
Send feedback
Help
如何设计实体关系来更好的实现跨级查询
1 view
Skip to first unread message
Jason Ye
unread,
Dec 5, 2006, 4:52:37 AM
12/5/06
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to NBear Google Group
比如有Category、Product、Item三个实体,Category与Product之间,以及Product与Item之间都是1对多的关系。
如果我想直接查询某一个Category下面的所有Item,除了先返回Product[],再返回Item[],是否还有好的办法,可以减少实际产生的SQL语句。
Teddy
unread,
Dec 5, 2006, 6:36:49 AM
12/5/06
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nbear...@googlegroups.com
没有特别方便的办法,不过,一般,复杂(关联)查选,建议用存储过程查询或直接用sql查询,将返回的结果填充到实体。
例如,可以使用Gateway.FindArray<Entity>(string sql, params object[] paramValues)重载使用自定义sql查询返回Items,但是注意,自定义sql的select的列的顺序必须和Item的属性定义一致。
Teddy
Reply all
Reply to author
Forward
0 new messages