1

我浏览了几个 asp.net 申请表 asp.net

我看到一些示例不使用像http://www.asp.net/downloads/starter-kits/job这样的OOP 聚合或包含 ,例如开发人员在我的职位发布类和公司类中使用 countryID 而不是国家对象。

我想知道是否推荐这种方式在此处输入图像描述

 public class JobPosting
    {

        #region Member Variables

        private int intJobPostingID;
        private int intCompanyID;
        private string strContactPerson;
        private string strTitle;
        private string strDepartment;
        private string strJobCode;
        private string strCity;
        private int intStateID;
        private int intCountryID;
        private int intEducationLevelID;
        private int intJobTypeID;
        private decimal dblMinSalary;
        private decimal dblMaxSalary;
        private string strDescription;
        private DateTime dtPostingDate=DateTime.Now;
        private string strPostedBy=HttpContext.Current.Profile.UserName;

   }

   public class Country
   {


        private string strCountryName;
        private int intCountryID;
        public Country()
        {
        }
   }


    public class Company
    {
        private int intCompanyID;
        private string strUserName;

        private string strCompanyName;
        private string strBriefProfile;

        private string strAddress1;
        private string strAddress2;
        private string strCity;
        private int intStateID;
        private int intCountryID;
        private string strZIP;

        private string strPhone;
        private string strFax;
        private string strEmail;
        private string strWebSiteUrl;
}
4

1 回答 1

1

在您展示的示例中,建议包括 Country 而不是 countryId。ORM 框架专门用于此目的。领域模型应该遵循组合和继承等oop原则,而ORM将弥合DB和领域模型之间的鸿沟。

于 2013-04-27T03:37:52.600 回答