title: Unable to create a constant value of type 'EntityType'. Only primitive types or enumeration types are supported in this context
body: <p>I am using Entity Framework to run the following db2 SQL</p>
  
  <pre><code>SELECT CM98.TUCUS01.CUST_NO,   
       CM98.TUMHC08.APPL_DT,   
       CM98.TUUNI30.MDL_ID,   
       CM98.TUMHC08.APPL_ID,   
       CM98.TUMHC08.DLR_NO,   
       CM98.TUMHC07.STAT_CD_DESC_TX,   
       CM98.TUCUS01.LAST_NAME,   
       CM98.TUCUS01.FST_NAME,   
       CM98.TUMHC08.UN_ID,   
       CM98.TUMHC08.PL_ID  
  FROM CM98.TUSRV97,   
       CM98.TUMHC06,   
       CM98.TUMHC07,   
       CM98.TUCUS01,   
       CM98.TUUNI30,   
       CM98.TUMHC08  
  WHERE ( CM98.TUMHC08.APPL_ID = CM98.TUMHC06.APPL_ID ) and  
       ( CM98.TUMHC07.APPL_STAT_CD = CM98.TUMHC06.APPL_STAT_CD ) and  
       ( CM98.TUUNI30.UN_ID = CM98.TUMHC08.UN_ID ) and  
       ( CM98.TUSRV97.XPROD_DIV_CD = CM98.TUUNI30.XPROD_DIV_CD ) and  
       ( CM98.TUSRV97.XPROD_CD = CM98.TUUNI30.XPROD_CD ) and  
       ( CM98.TUSRV97.MDL_ID = CM98.TUUNI30.MDL_ID ) and  
       ( CM98.TUMHC08.CUST_NO = CM98.TUCUS01.CUST_NO ) and  
  ( ( "CM98"."TUMHC06"."APPL_STAT_TS" = (SELECT MAX(APPL_STAT_TS) FROM CM98.TUMHC06 WHERE APPL_ID = CM98.TUMHC08.APPL_ID) ) )
  </code></pre>
  
  <p>Below is the Linq query I created,</p>
  
  <pre><code>from SRV97 in db.TUSRV97
  from MHC06 in db.TUMHC06
  from MHC07 in db.TUMHC07
  from CUS01 in db.TUCUS01
  from UNI30 in db.TUUNI30
  from MHC08 in db.TUMHC08
  where
   MHC08.APPL_ID == MHC06.APPL_ID &amp;&amp;
   MHC07.APPL_STAT_CD == MHC06.APPL_STAT_CD &amp;&amp;
   UNI30.UN_ID == MHC08.UN_ID &amp;&amp;
   SRV97.XPROD_DIV_CD == UNI30.XPROD_DIV_CD &amp;&amp;
   SRV97.XPROD_CD == UNI30.XPROD_CD &amp;&amp;
   SRV97.MDL_ID == UNI30.MDL_ID &amp;&amp;
   MHC08.CUST_NO == CUS01.CUST_NO &amp;&amp;
   MHC06.APPL_STAT_TS == 
    (from tempTUMHC060 in db.TUMHC06
    where
     tempTUMHC060.APPL_ID == MHC08.APPL_ID
    select new {
     tempTUMHC060.APPL_STAT_TS
    }).Max(p =&gt; p.APPL_STAT_TS)
  select new {
   CUS01.CUST_NO,
   MHC08.APPL_DT,
   UNI30.MDL_ID,
   MHC08.APPL_ID,
   MHC08.DLR_NO,
   MHC07.STAT_CD_DESC_TX,
   CUS01.LAST_NAME,
   CUS01.FST_NAME,
   MHC08.UN_ID,
   MHC08.PL_ID
  }
  </code></pre>
  
  <p>I am getting an error
  <strong>Unable to create a constant value of type 'APP.Models.TUCUS01'. Only primitive types or enumeration types are supported in this context</strong></p>
  
  <p>I don't know what went wrong..Any idea?</p>
  
  <p>Thanks</p>