title: c# DAL class and business layer class
body: <p>HI,</p>
  
  <p>can you tell me if this is possible.</p>
  
  <pre><code>public class Person
  {
      public string Name { get; set; }
      public int ID { get; set; }
  }
  </code></pre>
  
  <p>Populate a class call say person which is in an assembly called Entities like this with the population of the code being done in a different assembly called DataAccessLayer (so person and the place where it is populated are not in the same assembly)</p>
  
  <p>//the below code would be reading from a datareader etc but have just done this to make it //easy to explain. </p>
  
  <pre><code>Person p=new Person();
  p.Name="tom";
  p.id = 10;
  </code></pre>
  
  <p>The person class is now to be made accessible to another system to allow them to be able to access person. What i would like is to prevent the other system from being able to change the ID. be able to read it but not write. Do i need to create another class etc to allow this and only expose this class to the other system (i.e. a business object) (i.e. ORM)?</p>
  
  <p>i know alot of people are going to say just make the ID readonly. i.e. </p>
  
  <pre><code>public int ID { get; }
  </code></pre>
  
  <p>but if i do this then i cannot populate the ID from the code similar to above because in my DataAccessLayer i will not be able to set the ID as it is readonly. </p>
  
  <p>thanks
  Niall </p>