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 .

4

1 回答 1

3

BLL 与表示层(ASP.Net 页面)对话 DAL 与数据库(SQL、Oracle 等)对话 BO 是 BLL 和 DAL 之间交换的对象。

您不必创建另一个 BO 来列出和添加数据。您可以将同一个 BO 对象用于这两种目的。

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

将您要用于单个对象的所有内容放在下面:

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();
于 2013-06-05T10:44:19.457 回答