title: StoredProcedure In EntityFramework DateTime Error
body: <p>In my project i have used EntityFramework 5 and I came up to use an SP in my Context. Like this</p>
  
  <pre><code>public virtual object GetEvaluations(int AgentId, DateTime StartDate, DateTime EndDate, int FormId)
  {
      DataTable table = new DataTable();
      using (DbDataAdapter adapter = new SqlDataAdapter())
      {
          adapter.SelectCommand = _context.Database.Connection.CreateCommand();
          adapter.SelectCommand.Parameters.Clear();
          adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
          adapter.SelectCommand.CommandText = "GetEvaluations";
  
          SqlParameter aid = new SqlParameter("@AgentId", SqlDbType.Int);
          aid.Value = AgentId;
          SqlParameter sd = new SqlParameter("@StartDate", StartDate.Date.ToString("dd.MM.yyyy"));
          SqlParameter ed = new SqlParameter("@EndDate", EndDate.Date.ToString("MM.dd.yyyy"));
          SqlParameter fid = new SqlParameter("@FormId", SqlDbType.Int);
          fid.Value = FormId;
  
          adapter.SelectCommand.Parameters.Add(aid);
          adapter.SelectCommand.Parameters.Add(sd);
          adapter.SelectCommand.Parameters.Add(ed);
          adapter.SelectCommand.Parameters.Add(fid);
  
          adapter.Fill(table);
      }
  
      return table;
  }
  </code></pre>
  
  <p>Here the DateTime formats different style but just working like this. Even this 2 parameters are looking to the same field in the table.</p>
  
  <p>Please look at datetime formats (they are different) i think they must be same style.</p>
  
  <p>My SP:</p>
  
  <pre><code>USE [EvaluationAssistt]
  GO
  /****** Object:  StoredProcedure [dbo].[GetEvaluations]    Script Date: 12.03.2015 11:25:08 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  -- =============================================
  -- Author:      Hammit Yildirim
  -- Create date: 11.03.2015
  -- Description: Defined for Category Point Reports Performance
  -- =============================================
  ALTER PROCEDURE [dbo].[GetEvaluations]-- 258,'1.11.2014','11.24.2014',8
  @AgentId int,
  @StartDate Datetime,
  @EndDate Datetime,
  @FormId int
  AS
  BEGIN
      SET NOCOUNT ON;
  
      select fce.Id from FormsCallsEvaluated fce
          left join FormsCalls fc on fce.CallId = fc.CallId
          where fc.AgentId=@AgentId and fc.DateStarted &gt; @StartDate and fc.DateStarted &lt; @EndDate and fce.FormId=@FormId
  END
  </code></pre>
  
  <p>What is my problem</p>
  
  <p>I tryed below and returning me empty table</p>
  
  <pre><code> public virtual object GetEvaluations(int AgentId, DateTime StartDate, DateTime EndDate, int FormId)
      {
          DataTable table = new DataTable();
          using (DbDataAdapter adapter = new SqlDataAdapter())
          {
              adapter.SelectCommand = _context.Database.Connection.CreateCommand();
              adapter.SelectCommand.Parameters.Clear();
              adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
              adapter.SelectCommand.CommandText = "GetEvaluations";
  
              SqlParameter aid = new SqlParameter("@AgentId", SqlDbType.Int);
              aid.SqlValue = AgentId;
              SqlParameter sd = new SqlParameter("@StartDate", SqlDbType.DateTime);
              sd.SqlValue = StartDate.Date;
              SqlParameter ed = new SqlParameter("@EndDate", SqlDbType.DateTime);
              ed.SqlValue = EndDate.Date;
              SqlParameter fid = new SqlParameter("@FormId", SqlDbType.Int);
              fid.SqlValue = FormId;
  
              adapter.SelectCommand.Parameters.Add(aid);
              adapter.SelectCommand.Parameters.Add(sd);
              adapter.SelectCommand.Parameters.Add(ed);
              adapter.SelectCommand.Parameters.Add(fid);
  
              adapter.Fill(table);
          }
  
          return table;
      }
  </code></pre>
  
  <p>It is working SQL side just like this</p>
  
  <pre><code>USE [EvaluationAssistt]
  GO
  
  DECLARE @return_value int
  
  EXEC    @return_value = [dbo].[GetEvaluations]
          @AgentId = 258,
          @StartDate = N'1.11.2014',
          @EndDate = N'11.24.2014',
          @FormId = 8
  
  SELECT  'Return Value' = @return_value
  
  GO
  </code></pre>