在我的分层架构项目中,来自数据库的选定数据通过业务对象类的列表类型从数据层传递到业务层。我在DataBase学生和工作人员中有两个表。业务对象层中的两个类,学生和工作人员.DataLayer返回自定义类类型的列表,如
List< student>和列表< staff>查询并从数据库中选择数据后的业务层。在一个场景中,我需要加入并从数据库中获取两个表中的数据,并将数据从数据层传递到业务层。如何从数据层传递数据列表?哪种方法最好? 谢谢, Amrutha Nair。
解决方案首先,应该是out,而不是ref。 其次,你可以声明并返回一个包含两个列表的类型。 第三,您可以声明一个通用元组并返回一个实例: 参见在C#中返回两个列表的最佳方法是什么? [ ^ ] 或 您可以将它们全部放在静态字典中。请参阅返回多个列表 [ ^ ]。
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[^].更多推荐
如何将数据从DataLayer返回到Business层?
发布评论