在对象层次结构中读取数据库结果集 [英] Reading DB Result sets in object hierarchy

查看:64
本文介绍了在对象层次结构中读取数据库结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在读取数据库结果并将其映射到我的类对象中
例如,在诸如客户订单和客户订单之类的情况下,我将客户作为选择命令读取,并将订单作为选择命令的下一个结果集,在读取器上,我移至下一个结果集并将其映射到''customer''对象.直到这里没事.

问题::如果我得到第三个结果集,就像每个客户订单的订单交易一样.
那么将这个第三结果集按层次结构映射到订单的好逻辑是什么.一种读取与第二结果集中的第N条记录相关的第三结果集中的n行的方法.

我正在执行此操作,以便可以在我的代码中执行以下操作.

orderTransaction[] transactions = customer.order[2].orderTransactions

感谢您的任何想法或逻辑.

Hey guys
I am reading the database result and mapping it to my class objects
for example in a case like customer and customer orders, I read customer as a select command and the orders as a next result set of select command, on reader I move to next result set and map it to the collection of ''customerOrders'' on ''customer'' object. Till here its ok.

Problem: if i got 3rd result set which is like order transactions for each order of a customer.
Then what would be the good logic to map this 3rd result set in hierarchy to orders. Some way to read n rows in 3rd result set which is related to the Nth record in 2nd result set.

I am Doing this so that I can do following in my code.

orderTransaction[] transactions = customer.order[2].orderTransactions

Thanks for any ideas or logic.

推荐答案

尚不清楚您用于实现应用程序的方式和框架.但是,如果您愿意使用 ADO实体框架 [ ^ ]或 NHibernate [
It is not clear how and what framework you used to implement your application. But, if you are comfortable working with ADO Entity Framework[^] or NHibernate[^], such kind of query propagation is really easy. Just explore them.


I hope this helps you well.


这篇关于在对象层次结构中读取数据库结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆