3层建筑在.Net [英] 3 Tier Architecture In .Net

查看:76
本文介绍了3层建筑在.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用asp.net中的3层架构创建名为Test的项目为此我已按照以下步骤操作 - >新项目 - > Asp.Net Web应用程序并命名为Test.UI现在我需要这个文件菜单的DAL,BLL图层添加新项目但不是New->项目我拿了类库并且跟BLL一样,我给了DAL的BLL参考但是当我在DAL中创建一个新类并重建时我无法在BLL项目中访问它的解决方案请帮助

解决方案

创建一个类库 - BusinessLogic。在UI图层项目中添加它的引用。

创建一个类库 - DataAccess。在BL层项目中添加它的引用。



现在,从您的UI中,使用对象模型并传递给BusinessLogic项目类。此类是业务逻辑类。根据您的需要进行更改。

现在,将已更改的数据从业务逻辑类传递到dataAccess项目类。在这个类中,使用ADO.NET并将所需的值传递给存储过程。



为了获取数据,它将从DA传输到BL然后BL到UI层。

看看这些,对样本的解释:

C#中的3层架构 [ ^ ]

3层体系结构示例 [ ^ ]

使用C#的ASP.NET中的3层架构 [ ^ ]



更多山姆这个答案中提供的链接: Visual C#的初学者项目使用VS / SQL 2005 [ ^ ]


 创建 < span class =code-leadattribute> class    name   it   as   想要        BOLpage  .cs 

然后 define 变量 您的 program as
折叠 | 复制 代码
private vST;

然后 创建 property 过程 get set values) as
折叠 | 复制 代码
public String ST
{
get
{
返回 vST;
}
set
{
vST = value;
}
}

define functions for 您的 程序 as
折叠 | 复制 代码
public void fun1(class_name objectOf_class_name)
{

}





为数据库交互创建DSLpage.cs的方式相同。



在您的代码隐藏页面上,调用两个类以供适当使用。


添加Dal的特定命名空间

Hi I'm Creating Project called Test using 3-tier architecture in asp.net for this i have followed these steps File->New Project->Asp.Net Web Application And Named as Test.UI now i need DAL, BLL Layers for this File Menu Add New Project but not New->Project and i took class library and followed same for BLL, I gave the reference for BLL of DAL but when i create a new class in DAL and rebuild-ed the solution i cannot access it in BLL project Please Help

解决方案

Create a class library - BusinessLogic. Add a reference of it in UI layer project.
Create a class library - DataAccess. Add a reference of it in BL layer project.

Now, from your UI, use the object model and pass on to BusinessLogic project class. This class is a Business logic class. Do the changes as per your need here.
Now, pass on the changed data from business logic class to dataAccess project class. In this class, use ADO.NET and pass on the needed values to Stored Procedure.

For getting back data, it will be transferred from DA to BL and then BL to UI layer.
Have a look at these, explaination with samples:
3-tier architecture in C#[^]
3-Tier Architecture Examples[^]
3-Tier Architecture in ASP.NET with C#[^]

More sample links provided in this answer: Beginner Projects for Visual C# with VS/SQL 2005[^]


create class and name it as you want, by it will be " BOLpage.cs"

then define every variable used in your program as
 Collapse | Copy Code
private vST;

then create property procedures ( which will get and set the values) as
 Collapse | Copy Code
public String ST
{
      get
      {
         return vST;
      }
      set
      {
          vST=value;
       }
}

and define functions for your programs as
 Collapse | Copy Code
public void fun1(class_name objectOf_class_name)
{

}

.



Same way create DSLpage.cs for Database interaction.

On your code-behind page , call both classes for appropriate use.


Add the particular namespace of the Dal


这篇关于3层建筑在.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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