我正在使用TableProfileProvider在n層體系結構中使用ASP.NET配置文件系統。
UI層是一個Web應用程序,所以我必須公開profilecommon類才能使用配置文件。
下面是我的架構簡化模式:
UI: ASP.NET Web應用程序。
商業實體:純POCO類。持久性Igronace。
BLL:業務邏輯層。
DAL:數據訪問層。在n層體系結構中添加對業務邏輯層的System.Web引用
的的ProfileCommon定義是:
的ProfileCommon strongleyTypedProfile =(的ProfileCommon)這樣的:
public class ProfileCommon : ProfileBase
{
public virtual ProfileCommon GetProfile(string username)
{
return (ProfileCommon)ProfileBase.Create(username);
}
public virtual string FirstName
{
get
{
return (string)base.GetPropertyValue("FirstName");
}
set
{
base.SetPropertyValue("FirstName", value);
}
}
}
在一個簡單的設計架構,一切都在Web應用程序項目如下定義我訪問的ProfileCommon。 Context.Profile;
我希望能夠從我的業務邏輯層訪問Profile常見,所以我感動的ProfileCommon定義,我BusinessEntities庫(不得不添加引用System.Web程序集在BusinessEntities庫),並確定新的ProfileBLL類:
public class ProfileInfo
{
public ProfileInfo(ProfileCommon profile)
{
this.Profile = profile;
}
public ProfileCommon Profile { get; set; }
public string GetFullName()
{
return this.Profile.FirstName + " " + this.Profile.LastName;
}
}
現在我可以從UI訪問常用的個人資料如下:
var profileInfo = new BLL.ProfileInfo((ProfileCommon)this.Context.Profile);
txtFullName.text = profileInfo.GetFullName();
現在,在業務層參考的System.Web/BusinessEntities庫違反了n層結構的學科?如果是這樣,你會建議如何實現這一目標?
@skaffman來實現你的web應用的
IProfile
界面的自由:此不是一個n層相關的問題。這與n層有關。當您在硬件級別有不同的層時,n層意味着。 – Kamyar 2011-01-25 23:05:03