1

私はいくつかのasp.netアプリケーションフォームasp.netを閲覧しました

http://www.asp.net/downloads/starter-kits/jobのような OOP Aggregation または Containment を使用しない例をいくつか見ます 。たとえば、開発者は私の求人情報クラスと会社クラスで国オブジェクトの代わりに国 ID を使用します。

この方法が推奨されているかどうか知りたいここに画像の説明を入力

 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

あなたが示した例では、countryId ではなく Country を含めることをお勧めします。ORM フレームワークは、そのためのものです。ドメイン モデルは、構成や継承などの oop の原則に従う必要があり、ORM は DB とドメイン モデルの間のギャップを埋めます。

于 2013-04-27T03:37:52.600 に答える