title: Properties private set;
body: <p>I know it only allows the class to set it, but what is the point?</p>
  
  <p>How do I solve the problem of having readonly ids?</p>
  
  <p>Say I have a person class:</p>
  
  <pre><code>public class Person
      {
          public string Name { get;  set; }
          public int Id { get; private set; }
          public int Age { get; set; }
      }
  </code></pre>
  
  <p>And this is in an <code>Entities.dll</code>, used by a GUI, BL and DAL.</p>
  
  <p>The GUI calls the BL:</p>
  
  <pre><code>   List&lt;Person&gt; p =  BL.PeopleBL.GetPeople();
  </code></pre>
  
  <p>For the sake of the example calls the DAL:</p>
  
  <pre><code>...
  while(dr.read())
  {
      returnPersonList.add( new Person{ Age=dr.GetInt32(1), Id=dr.GetInt32(0), Name=dr.GetString(2)})
  }
  ...
  </code></pre>
  
  <p>of course I cannot do that cause Id is a private set;
  What is the proper way to do this?</p>
  
  <p>How can I let the BL/Dal set the Id, but not on the GUI?</p>
  
  <p>Or is this not even the proper use of a private set?</p>
  
  <hr>
  
  <p>I just wanted to add that this is your typical DB app, where the pk is the Id and should not be changed( only by the BL/DAL)</p>
  
  <hr>