0

This code is Working

  public virtual List<mbSummary_Result> mbSummary(Nullable<System.DateTime> fromDate,
        Nullable<System.DateTime> toDate)
    {
        var fromDateParameter = fromDate.HasValue
            ? new ObjectParameter("FromDate", fromDate)
            : new ObjectParameter("FromDate", typeof(System.DateTime));
        var toDateParameter = toDate.HasValue
            ? new ObjectParameter("ToDate", toDate)
            : new ObjectParameter("ToDate", typeof(System.DateTime));

        var result = ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<mbSummary_Result>("mbSummary",
            fromDateParameter, toDateParameter).ToList();

        return result;
    }

but when it produce so many rows it returns with this error:

An unhandled exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll

Additional information: An error occurred while executing the command definition. See the inner exception for details.

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • As the exception message stated, please see inner exception details and include it with current stack trace in your question. – Tetsuya Yamamoto Sep 13 '18 at 08:26
  • InnerException is this. {"Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding."} – user3410460 Sep 13 '18 at 08:28
  • 1
    Sounds like `mbSummary` taking too long time to finish. You can set `CommandTimeout` or use `EXEC sp_updatestats` as provided [here](https://stackoverflow.com/questions/8602395/timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation) and [here](https://stackoverflow.com/questions/49047767/the-timeout-period-elapsed-prior-to-completion-of-the-operation-or-the-server-is). – Tetsuya Yamamoto Sep 13 '18 at 08:32
  • Yesss ! That saved me. Thank youu ! – user3410460 Sep 13 '18 at 08:48

0 Answers0