4

I need your advice. I am trying to develop a 3 layer architecture in ASP.NET that separates BBL,DAL,BOboj.

Inside the DAL, I collect the data via _view. What I wonder, should I write another BOboj for every view??I have already has a BOboj class but it doesn't contain all fields.

When inserting data, I have to use my BOboj,however, when listing, should I create BOboj_view class or another something ??

inserting data (My colum only contains those values)

BOboj {
        private int _PId;
        private string _Name;
        private int _ClassId;

}

listing data

BOboj_view {

        private int _PId;
        private string _Name;
        private string _ClassName;
}

What's the best solution ,

thank you .

1 Answers1

3

BLL talks to the Presentation Layer (ASP.Net pages) DAL talks to the Database (SQL, Oracle, etc) BO are the objects exchanging between BLL and DAL.

You don't have to create another BO for listing and adding data. You can use the same BO object for both purposes.

Ref: http://msdn.microsoft.com/en-us/library/aa581779.aspx

Put everything you want to use for the single object like the following:

BOboj {
        private int _PId;
        private string _Name;
        private int _ClassId;
        private string _ClassName;
}

SqlCommand cmd = new SqlCommand("SPName");

cmd.Parameters.AddWithValue("@PID", obj.PID);
cmd.Parameters.AddWithValue("@Name", obj.Name);
cmd.Parameters.AddWithValue("@ClassID", obj.ClassID);

cmd.ExecuteNonQuery();
TTCG
  • 8,805
  • 31
  • 93
  • 141
  • I pass the object,not the values like this productLogic.UpdateProduct("Scott's Tea", 1, 1, null, -14m, 10, null, null, false, 1); –  Jun 05 '13 at 10:50
  • Your question is "should I create BOboj_view class or another something ??" The answer is "NO". You can use the same BO objects to transfer data between different layers. – TTCG Jun 05 '13 at 10:57
  • in this case ,when inserting data,i have to asign nothing to "private string _ClassName;" and others,that doesnt cause redundancy or,throw exceptin when insering or reading data?? –  Jun 05 '13 at 12:46
  • if you are not using ClassName in data insertion, you don't have to worry about. See my latest answer. – TTCG Jun 05 '13 at 13:10
  • thank you your answer.we are doing same thing when data inserting.but my question differen.look,I have 20 views and 40 class which mapped to tables inside sql server ,all views collect diffrent tables(that means different objects).should I creates 20 more class except of 40 ??I hope I can express myself. –  Jun 05 '13 at 14:10
  • My Question would be "Do you have to use the BO to display the data on the page?" If I were you, I will just pass DataTable from DAL to BL and display it on the page. I don't always use BO to display. I use it only if I have to. – TTCG Jun 05 '13 at 14:13
  • take a look at this,this is what structure I use http://stackoverflow.com/questions/16937221/bll-dal-obj-and-3-layer-architecture –  Jun 05 '13 at 14:26