BLL、DAL、BO、插入数据 [英] BLL,DAL,BO,inserting data

查看:27
本文介绍了BLL、DAL、BO、插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的建议.我正在尝试在 ASP.NET 中开发一个分离 BBL、DAL、BOboj 的 3 层架构.

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

在 DAL 内部,我通过 _view 收集数据.我想知道,我应该为每个视图编写另一个 BOboj 吗??我已经有一个 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.

插入数据时,我必须使用我的 BOboj,但是,在列出时,我应该创建 BOboj_view 类还是其他什么??

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;

}

列表数据

BOboj_view {

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

什么是最好的解决方案,

What's the best solution ,

谢谢.

推荐答案

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

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.

您不必创建另一个 BO 来列出和添加数据.您可以为这两个目的使用相同的 BO 对象.

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

参考: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();

这篇关于BLL、DAL、BO、插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆