解决方法
1)应用基础设施
>所有业务对象的基类,业务对象集合,数据访问类和我的自定义属性和实用程序作为扩展方法,通用验证框架.这决定了我的最终.net应用程序的整体行为组织.
2.)Application.DataModel
>数据库的类型化数据集.
> TableAdapters扩展到可以包含交易和其他功能.
3.)Application.DataAccess
>数据访问类.
>使用基础类型化数据集查询数据库操作的实际位置.
4.)Application.DomainObjects
>业务对象和业务对象集合.
枚举.
5.)Application.BusinessLayer
>提供从Presentation层访问的管理员类.
> HttpHandlers.
>我自己的页面基类.
>更多的东西去这里..
6.)Application.WebClient或Application.WindowsClient
>我的演示层
>从Application.BusinessLayer和Application.BusinessObjects引用.
Application.BusinessObjects跨越应用程序使用,并且每当需要时跨越所有层次[除了Application.DataModel和Application.Infrastructure]
我的所有查询都仅定义Application.DataModel.
Application.DataAccess返回或将业务对象作为任何数据访问操作的一部分.在反射属性的帮助下创建业务对象.每个业务对象都标有与数据库中的目标表的属性映射,业务对象中的属性将标记为映射到相应数据库表中的目标列的属性.
我的验证框架允许我在指定的ValidationAttribute的帮助下验证每个字段.
我的框架大量使用属性来自动执行大多数繁琐的任务,如映射和验证.我也可以将新功能作为框架的新方面.
在我的应用程序中,示例业务对象将如下所示.
User.cs
[TableMapping("Users")] public class User : EntityBase { #region Constructor(s) public AppUser() { BookCollection = new BookCollection(); } #endregion #region Properties #region Default Properties - Direct Field Mapping using DataFieldMappingAttribute private System.Int32 _UserId; private System.String _FirstName; private System.String _LastName; private System.String _UserName; private System.Boolean _IsActive; [DataFieldMapping("UserID")] [DataObjectFieldAttribute(true,true,false)] [NotNullOrEmpty(Message = "UserID From Users Table Is required.")] public override int Id { get { return _UserId; } set { _UserId = value; } } [DataFieldMapping("UserName")] [Searchable] [NotNullOrEmpty(Message = "Username Is required.")] public string UserName { get { return _UserName; } set { _UserName = value; } } [DataFieldMapping("FirstName")] [Searchable] public string FirstName { get { return _FirstName; } set { _FirstName = value; } } [DataFieldMapping("LastName")] [Searchable] public string LastName { get { return _LastName; } set { _LastName = value; } } [DataFieldMapping("IsActive")] public bool IsActive { get { return _IsActive; } set { _IsActive = value; } } #region One-To-Many Mappings public BookCollection Books { get; set; } #endregion #region Derived Properties public string FullName { get { return this.FirstName + " " + this.LastName; } } #endregion #endregion public override bool Validate() { bool baseValid = base.Validate(); bool localValid = Books.Validate(); return baseValid && localValid; } }
BookCollection.cs
/// <summary> /// The BookCollection class is designed to work with lists of instances of Book. /// </summary> public class BookCollection : EntityCollectionBase<Book> { /// <summary> /// Initializes a new instance of the BookCollection class. /// </summary> public BookCollection() { } /// <summary> /// Initializes a new instance of the BookCollection class. /// </summary> public BookCollection (IList<Book> initialList) : base(initialList) { } }