Exemplo n.º 1
0
        public IEnumerable <ParametroValor> GetAll()
        {
            List <ParametroValor> parametrosValores = new List <ParametroValor>();

            using (SqlConnection connection = new SqlConnection(this.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = "SELECT pv.Id, pv.IdTestData, pv.Valor, p.ColunaTecnicaTosca, p.Id IdParametro FROM[TDM.Db].[dbo].[ParametroValor] pv INNER JOIN[TDM.Db].[dbo].[ParametroScript] ps on pv.IdParametroScript = ps.Id INNER JOIN[TDM.Db].[dbo].[Parametro] p on ps.IdParametro = p.Id";

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        ParametroValor pv = new ParametroValor
                        {
                            Id                 = reader["Id"] == DBNull.Value ? 0 : Convert.ToInt32(reader["id"]),
                            IdTestData         = Convert.ToInt32(reader["IdTestData"]),
                            IdParametro        = Convert.ToInt32(reader["IdParametro"]),
                            DescricaoParametro = reader["ColunaTecnicaTosca"].ToString(),
                            Valor              = reader["Valor"].ToString()
                        };
                        parametrosValores.Add(pv);
                    }
                }
                connection.Close();
            }
            return(parametrosValores);
        }
Exemplo n.º 2
0
        public ParametroValor Get(int IdTestData)
        {
            ParametroValor pv = new ParametroValor();

            using (SqlConnection connection = new SqlConnection(this.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = "SELECT pv.Id, pv.IdTestData, pv.Valor, p.ColunaTecnicaTosca, p.Id IdParametro FROM[TDM.Db].[dbo].[ParametroValor] pv INNER JOIN[TDM.Db].[dbo].[ParametroScript] ps on pv.IdParametroScript = ps.Id INNER JOIN[TDM.Db].[dbo].[Parametro] p on ps.IdParametro = p.Id WHERE pv.IdTestData = " + IdTestData + " AND ps.IdTipoParametro = 1";

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        pv = new ParametroValor
                        {
                            Id                 = reader["Id"] == DBNull.Value ? 0 : Convert.ToInt32(reader["id"]),
                            IdTestData         = Convert.ToInt32(reader["IdTestData"]),
                            IdParametro        = Convert.ToInt32(reader["IdParametro"]),
                            DescricaoParametro = reader["ColunaTecnicaTosca"].ToString(),
                            Valor              = reader["Valor"].ToString()
                        };
                        //pv.Add(ob);
                    }
                }
                connection.Close();
            }
            return(pv);
        }