Search code examples
asp.net3-tier

Returning data from the business layer to the presentation layer


I am developing an ASP.NET 2.0 website. I have created data access and business logic layers. Now in the presentation layer I am returning data from the business layer as a dataset.

My question is whether to use a dataset or object collection (for example a Category object representing the Category table in my database). I have defined all classes that are mapped to database tables (Common objects). But there are situations where I need all of the records from the category table in the presentation layer. I am just confused. What should I do?


Solution

  • You don't want to return datasets, you want to return objects.

    Generally when you have a data access layer and a business logic layer you will also want to have an entity layer. The entity layer will be an in memory repersentation of the database result set. If you return one row from the database you load one entitiy object. If you return more than one row, you will load an entity for each row, and return a collection of entities to be consumed by the presentation layer.

    If you're using .net 2.0 and above for example, you can create generic collections of the entity type and easily bind different types of controls to these collections.

    Hope this is helpful for you.