When does an object's property become available?
<p><em>Foreword: this is a long question and if you don't want to read and understand why I'm asking it then please spare the comment "why not simply test the code?"</em></p>

<p>I have an object model that looks somewhat like this:</p>

<pre><code>public class MyObjectModel
{
     public byte TypeOfNestedObject { get; set; } 
     public string NestedObjectInJson { get; set; }

     public NestedObjectModel1 { get; set; }
     public NestedObjectModel2 { get; set; }
     public NestedObjectModel3 { get; set; }

     public MyObjectModel()
     {
         NestedObjectModel1 = null;
         NestedObjectModel2 = null;
         NestedObjectModel3 = null;
     }

     public void DeserializeJsonString()
     { 
          if (TypeOfNestedObject == 1) { 

              NestedObjectModel1 = "deserialize NestedObjectInJson 
                                    into NestedObjectModel1";
          }

          if (TypeOfNestedObject == 2) { 

              NestedObjectModel2 = "deserialize NestedObjectInJson 
                                    into NestedObjectModel2";
          }

          if (TypeOfNestedObject == 3) { NestedObjectModel3 ... }
     }
}
</code></pre>

<p>Basically, the object is composed of three nested objects (<code>NestedObjectModel1</code>, <code>NestedObjectModel2</code> and <code>NestedObjectModel3</code>). However, only one of them is actually used at any given time. In the database, I store fields that are used to recreate this object and one of the database fields is a json string that contains one of the three nested objects for a particular instance.</p>

<p>My query looks somewhat like this:</p>

<pre><code>var TheObjectModel = from t in MyDC.Table
                     .....
                     select new MyObjectModel()
                     {
                         TypeOfNestedObject = t.TypeOfNestedObject,

                         NestedObjectInJson = t.NestedObjectInJson  
                     };
</code></pre>

<p>I use the property <code>TypeOfNestedObject</code> to know which nested object the particular instance of <code>MyObjectModel</code> has. <strong>For the moment,</strong> after the the query has executed, I run a method that reads <code>TypeOfNestedObject</code> and deserializes the string <code>NestedObjectInJson</code> to the appropriate type and adds the deserialized object as the corresponding nested object.</p>

<p><strong>Now I want to add a custom setter</strong> to <code>NestedObjectInJson</code> so that when this property is set when the query runs, the object automatically deserializes the string to the appropriate type. However, for this to work, the object would also have to have the property <code>TypeOfNestedObject</code> properly set. I want to write the setter like this:</p>

<pre><code>public NestedObjectInJson
{
   set {

       if (this.TypeOfNestedObject == 1) {

            NestedObjectModel1 = "deserialize NestedObjectInJson 
                                  into NestedObjectModel1 ";
       }
   }
}
</code></pre>

<p>If I write the setter like this, is the property TypeOfNestedObject needs to be available at the time the setter runs. If you notice, in the query, I load <code>TypeOfNestedObject</code> before I load <code>NestedObjectInJson</code>. </p>

<p>So the question is this: If I decide to remove the call to <code>DeserializeJsonString</code> and create this custom setter, will the property TypeOfNestedObject be available because in the query it's set before <code>NestedObjectInJson</code> or is the order in which the query is written make the availability of the property <code>TypeOfNestedObject</code> unpredictable?</p>
