EF执行存储过程时超时问题

 public DataSet ExecuteProcedure(string Procedure, IDataParameter[] parameters)
        {
            using (ContextEntities Entities = new ContextEntities())
            {
                using (Entities.Database.Connection.CreateConnectionScope())
                {
                    var cmd = Entities.Database.Connection.CreateCommand();
                    cmd.CommandTimeout = 5000;
                    cmd.CommandText = Procedure;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddRange(parameters);
                    SqlDataAdapter f = new SqlDataAdapter(cmd as SqlCommand);
                    DataSet ds = new DataSet();
                    f.Fill(ds);
                    return ds;
                }
            }
        }

 

posted @ 2022-07-12 09:02  冬月二四  阅读(220)  评论(0编辑  收藏  举报