title: How do you write a parameterized where-in raw sql query in Entity Framework
body: <p>How do you write a parameterized where-in raw sql query in Entity Framework? I've tried the following:</p>
  
  <pre><code>string dateQueryString = String.Join(",", chartModelData.GetFormattedDateList());
  //Dates returned in format of 20140402,20140506,20140704
  
  const string selectQuery = 
      @"SELECT 
           MAX(DATA_SEQ) AS MaxSeq, MIN(DATA_SEQ) AS MinSeq, COUNT(1) AS TotSampleCnt
        FROM SPCDATA_TB
        WHERE DATA_WDATE IN @DateParam  
        AND LINE_CODE = @LineCode
        AND MODEL_NO = @ModelNumber
        AND LOT_NO = @LotNumber
        AND EQUIP_NO LIKE @EquipNumber";
  
  SPCDataSeqCntInfo dataSeqCntInfo = _dbContext.Database.SqlQuery&lt;SPCDataSeqCntInfo&gt;(
        selectQuery,
        new SqlParameter("@DateParam",   dateQueryString),
        new SqlParameter("@LineCode",    chartModelData.LineCode),
        new SqlParameter("@ModelNumber", chartModelData.ModelNum),
        new SqlParameter("@EquipNumber", equipmentNumber),
        new SqlParameter("@LotNumber",   chartModelData.LotNum)
    ).SingleOrDefault() ?? new SPCDataSeqCntInfo();
  </code></pre>
  
  <p>But as expected, it throws an error on DateParam because it's expecting a single value.</p>