title: Set EntityCollection in a Linq projection
body: <p>I would like to know how I can set an EntityCollection in a Linq Projection.
  Below is my code:</p>
  
  <pre><code>var orders = (from order in context.Orders
     select new
     {
      reference = order.reference,
      pe = order.OrderExecutions //this is an EntityCollection
     })
  .AsEnumerable()
  .Select(o =&gt;
       (Orders)new Orders
       {
        reference = o.reference,
        OrderExecutions = o.pe
       }
  ).ToList().AsQueryable();
  </code></pre>
  
  <p>(This code seems weird but it needs to be like this in order to work in a telerik grid)</p>
  
  <p>The instruction <code>OrderExecutions = o.pe</code> involves this error:</p>
  
  <blockquote>
    <p>The EntityCollection has already been
    initialized. The
    InitializeRelatedCollection method
    should only be called to initialize a
    new EntityCollection during
    deserialization of an object graph.</p>
  </blockquote>
  
  <p>OrderExecutions is an EntityCollection contained in the object Orders.</p>
  
  <p>How can I avoid this error? Any idea?</p>
  
  <p>Should I modify the generated code in the Order object?</p>
  
  <pre><code>[XmlIgnoreAttribute()]
  [SoapIgnoreAttribute()]
  [DataMemberAttribute()]
  [EdmRelationshipNavigationPropertyAttribute("PModel", "FK__orderExec__refer__70DDC3D8", "OrderExecutions")]
  public EntityCollection&lt;OrderExecutions&gt; OrderExecutions
  {
   get
   {
    return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection&lt;OrderExecutions&gt;("PModel.FK__orderExec__refer__70DDC3D8", "OrderExecutions");
   }
   set
   {
    if ((value != null))
    {
     ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection&lt;OrderExecutions&gt;("PModel.FK__orderExec__refer__70DDC3D8", "OrderExecutions", value);
    }
   }
  }
  </code></pre>
  
  <p>Thank you in advance.</p>