2010-06-25 62 views
0

我正在亞音速SimpleRepository的使用亞音速簡單的資料庫 - 堅持私有財產

我有一個類:

public class X{public string abc {get; set;}private string def {get; set;}} 

財產「高清」只是這個類中的設置,我不希望屬性是外部可見的,但由於某種原因,當我使用Repo.Save(x)保存對象時,私有屬性不會持久保存到數據庫中

任何幫助?

回答

1

設置了兩個數據模型,代表了在前端X(公共,可見)和一個代表在後端X(私有,隱藏):

namespace App.BackEnd // classes here are used for database storage 
{ 
    public class X 
    { 
     public string abc { get; set; } 
     public string def { get; set; } 

     public FrontEnd.X ToFrontEnd() 
     { 
      return new FrontEnd.X 
      { 
       abc = abc 
      }; 
     } 
    } 
} 

namespace App.FrontEnd // classes here are used for public interfaces 
{ 
    public class X 
    { 
     public string abc { get; set; } 
    } 
}