title: Any way to work around linq2Entities exception - Unable to create a constant value of type 'System.Object'.
body: <p>The scenario is</p>
  
  <pre><code>void someFunc(object obj1 )
  {
  
    using ( var ctx = getContext() )
    {
      var list = ctx.MyTable.Where ( .... ).OrderBy( ... ).Select (
        x =&gt; new PocoObject
        {
            string = x.String,
            ....
            // Command = new MyCommand { prop1 = x } // working code 
            Command = new MyCommand { prop1 = x, objProp = obj1 } // problem line
        }
        ).ToList();
  
        //list.ForEach( x =&gt; x.Command.objProp = obj1 ); working code
    }
  
  }
  </code></pre>
  
  <p>The exception is</p>
  
  <p>Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context</p>
  
  <p>changing the problem line with the code marked working code solves the issue</p>
  
  <p>Is there any way to tweak it to make it simpler i.e. without the ForEach at the end ?</p>