Business Layer/Data Layer RRS feed

  • Question

  • User-1004626193 posted


     I have one application which contains Business Layer and Data Layer. I am trying to use “Data Access Application Block” in Data layer. I am passing one parameter to one stored procedure and retrieving data based on that parameter. That data will stored in DataReader/IDataReader object. Now I want to use this Data Reader object (which contains result from Stored Procedure) in to business Layer and have to implement List Object. I am working on .NET and database is SQL Server 2005.

    Can anyone please guide me that from where to start and how to do this task. I am new in this field so it is challengeable for me to do this task. Please get me back ASAP……

    Let me know if you need any further information

    Thank you ..Pari


    Friday, May 18, 2007 10:40 AM

All replies

  • User-239621420 posted


    This is a lengthy topic to discuss, but with a very general answer, it sounds like what you are talking about is Object Relation Mapping.  There a lot of tools out there that will generate mapping from the database into your object's properties.  

    You could go a couple of approaches.

    1) If you want to mix data elements in your objects, you could have a load method in your object or a constructor that takes a datareader.  Then you could map the properties up like this.

    YourObject(IDataReader reader)
        _yourProp = (string)reader["YourPropsColumn"];

    You would do this for all properties.

    2) You could look at writing a set of data mappers.  Martin Fowler wrote a book called Patterns of Enterprise Application Architecture that has tons of solutions to common problems like this.  The one that would apply in your case would the DataMapper http://martinfowler.com/eaaCatalog/dataMapper.html


    Once you've got the mapping down, adding the into a List<> of your objects should be pretty straightfoward.  Again, this a lengthy topic to discuss and this is by no means an all inclusive answer. Just hopefully something to get you going in the right direction.  Feel free to message me or reply with more questions.

    Good luck. The next steps will be a lot of fun.

    Friday, May 18, 2007 11:21 AM
  • User-1004626193 posted


       I got your poing...thanks for your posting ...It did not solve my problem 100% but it gave me starting point....from whr i can move forward....

    thanks....I will let you know if I need any further guidlines.....


    Friday, May 18, 2007 1:24 PM