Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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.
Posted
Updated 31-Jul-14 0:43am
v3
Comments
Ziee-M 31-Jul-14 9:20am    
Hi, i think you have an issue in your model since you have student and stuff class in both DataLayer and buisness layer !
I think your real issue is how to do it best rather then how.
First, there is no "best solution" here ! it really depends on your needs. using an ORM or classic sql also have an impact on your global architecture.
You may read this article, althought its not exactly your need because the writer is using dataTable to pase Data beetwen layers, but, you will learn a lot and it will help you make your choice.

http://www.codeproject.com/Articles/493389/Four-ways-of-passing-data-between-layers

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900