将类库划分为物理层,作为N层应用程序 [英] class libraries into Physical separation as N-Tier Application

查看:77
本文介绍了将类库划分为物理层,作为N层应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请任何人可以帮助我了解我的项目.我无法将connString从web.config文件访问到在同一解决方案中作为类库项目物理隔离的BO和DA层.虽然我读了很多文章,但我不明白这样的体系结构.我在DA层中有CRUD方法和实体类.我只想在DA中验证DB方法.
如果我需要以类似下面的方式在BaseClass中编写它,则假设要获取我的conString.需要为connStr声明带构造函数的构造函数,不带参数作为connectionString.和朋友的财产.我不知道这两个类应该是私有的还是公共的,但是我在DNNuke站点体系结构中看到过这样的方法.请您以这种方式帮助我,先生,我将非常感谢.我尝试过但是出现很多错误,例如格式不正确"或无效的连接字符串...."
请允许我帮我从一层访问另一层的类.谢谢您

Please can anyone help me to understand my project. I am unable to access connString from web.config file to my BO and DA layers which are physically separated as class library projects in the same solution. Though i have read many articles but I can''t understand such architecture. I have CRUD methods and Entity Classes in DA layer. All I want is to validated DB method in DA only.
suppose to get my conString if i need to write it in BaseClass in a fashion like below. Need to declare Constructors for connStr with argument and without arguments as connectionString. And a friend Property. I dont know either class should be private or public but such method i have seen in DNNuke site architecture. Please if you can help me in this way then sir i would be very much thankful. I tried But alot of errors like "The format is incorrect" or "Invalid connection String...."
Please could you favour me how to access my classes from one layer to another.Thank you

推荐答案

您应该构造DAL类,使其具有使用连接字符串的构造函数最好是控制它的基类.

You should construct the DAL classes to have a constructor that takes a connection string and preferably a base class to control it.

public abstract class MyDALBase
{
  public MyDALBase()
  {
    // Set default connection string
  }

  public MyDALBase(string connString)
  {
    ConnectionString = connString;  
  }

  protected string ConnectionString{get; private set;}
}

public class MyDAL : MyDALBase
{
  public MyDAL() : base(){}
  public MyDAL(string connString) : base(connString){}
}



您应该查看诸如企业库数据访问应用程序块之类的框架. IMO



You should look at frameworks like the Enterprise Library Data Access Application Block. DNN is not a good implementation for anything, IMO


这篇关于将类库划分为物理层,作为N层应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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