Exemplo n.º 1
0
        public IList <T> ExecuteSQL(string sql)
        {
            MySqlCommand command;
            IList <T>    retornoObj = null;

            var connObj = GetConnection();

            try
            {
                if (connObj.State != ConnectionState.Open)
                {
                    connObj.Open();
                }

                command = new MySqlCommand(sql, (MySqlConnection)connObj);

                var retornoBanco = command.ExecuteReader();

                var retornoBancoMapeado = MapaDAL <T> .MapReader(retornoBanco);

                retornoObj = retornoBancoMapeado;
            }
            catch
            {
            }
            finally
            {
                if ((connObj.State != ConnectionState.Broken) || (connObj.State != ConnectionState.Closed))
                {
                    connObj.Close();
                }
            }
            return(retornoObj);
        }
Exemplo n.º 2
0
        public IList <T> Teste2(string sql)
        {
            IList <T>     retornoObj     = null;
            SqlConnection sqlConnection1 = new SqlConnection(GetConnectionString());
            SqlCommand    cmd            = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = sqlConnection1;

            sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            // Data is accessible through the DataReader object here.

            if (reader.Read())
            {
                var retornoBancoMapeado = MapaDAL <T> .MapReader(reader);

                retornoObj = retornoBancoMapeado;
            }

            sqlConnection1.Close();



            return(retornoObj);
        }
Exemplo n.º 3
0
        public IList <T> ExecuteReader(string pComando)
        {
            IDbCommand cmdObj     = null;
            IList <T>  retornoObj = null;

            var connObj = GetConnection();

            try
            {
                if (connObj.State != ConnectionState.Open)
                {
                    connObj.Open();
                }

                cmdObj = GetCommand(connObj, pComando);

                var retornoBanco = cmdObj.ExecuteReader();

                var retornoBancoMapeado = MapaDAL <T> .MapReader(retornoBanco);

                retornoObj = retornoBancoMapeado;
            }
            catch (Exception e)
            {
                //Logger.GetInstance().Erro(e);
            }
            finally
            {
                if ((connObj.State != ConnectionState.Broken) || (connObj.State != ConnectionState.Closed))
                {
                    connObj.Close();
                }
            }
            return(retornoObj);
        }
Exemplo n.º 4
0
        public T ExecuteReaderSingle(string pComando, CommandType pTipoComando, List <IDbDataParameter> pParametros)
        {
            T retornoObj = default(T);

            IDbCommand cmdObj  = null;
            var        connObj = GetConnection();

            try
            {
                if (connObj.State != ConnectionState.Open)
                {
                    connObj.Open();
                }

                cmdObj = GetCommand(connObj, pComando);

                var dr = cmdObj.ExecuteReader();
                if (dr.Read())
                {
                    retornoObj = MapaDAL <T> .MapRecord(dr);
                }
            }
            catch (Exception e)
            {
                //Logger.GetInstance().Erro(e);
            }
            finally
            {
                if ((connObj.State != ConnectionState.Broken) || (connObj.State != ConnectionState.Closed))
                {
                    connObj.Close();
                }
            }

            return(retornoObj);
        }