BLL,DAL,BO,inserting data

隐身守侯 提交于 2019-12-22 09:08:06

问题


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:


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();


来源:https://stackoverflow.com/questions/16936761/bll-dal-bo-inserting-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!