如何将数据从DataLayer返回到Business层? [英] How to return data from the DataLayer to Business layer?

查看:54
本文介绍了如何将数据从DataLayer返回到Business层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的分层架构项目中,来自数据库的选定数据通过业务对象类的列表类型从数据层传递到业​​务层。我在DataBase学生和工作人员中有两个表。业务对象层中的两个类,学生和工作人员.DataLayer返回自定义类类型的列表,如

 List< student>和列表< staff> 

查询并从数据库中选择数据后的业务层。在一个场景中,我需要加入并从数据库中获取两个表中的数据,并将数据从数据层传递到业​​务层。如何从数据层传递数据列表?哪种方法最好?



谢谢,

Amrutha Nair。

解决方案

< blockquote>首先,应该是out,而不是ref。



其次,你可以声明并返回一个包含两个列表的类型。



第三,您可以声明一个通用元组并返回一个实例:



参见在C#中返回两个列表的最佳方法是什么? [ ^ ]







您可以将它们全部放在静态字典中。请参阅返回多个列表 [ ^ ]。



- Amy

Hi,
In my project which is in layered architecture , the selected data from database is passed from the datalayer to business layer through list type of business object class. I have two table in the DataBase student and staff. Two classes in the bussiness object layer also, student and staff.The DataLayer is returning List of custom class type like

List <student>  and List<staff>

to bussiness layer after querying and selecting the data from the database. In a scenario i need to join and get the data from the two tables form the database and pass the data from datalayer to business layer. How can i pass a list of data from the datalayer? Which is the best method?

Thanks,
Amrutha Nair.

解决方案

First of all, that should probably be out, not ref.

Second, you can declare and return a type containing the two lists.

Third, you can declare a generic Tuple and return an instance of that:

See What is the best way to return two lists in C#?[^]

OR

You could put them all in a static Dictionary. See Return multiple list[^].

--Amy


这篇关于如何将数据从DataLayer返回到Business层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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