如何将数据从DataLayer返回到Business层?

编程入门 行业动态 更新时间:2024-10-27 00:27:10
本文介绍了如何将数据从DataLayer返回到Business层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

List< student>和列表< staff>

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

解决方案

首先,应该是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层?

本文发布于:2023-05-31 10:03:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   数据   Business   DataLayer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!