Example #1
0
        public async Task <ResponseDatos> GetDatosNotUsing()
        {
            var output = new ResponseDatos();

            string _query = "select Id,Valor from DatosPrueba";

            var conn = new SqlConnection(_connectionString);
            await conn.OpenAsync();

            var datos = await conn.QueryAsync <ObjetoDatosTest>(_query);

            output.Data = datos.ToList();


            return(output);
        }
Example #2
0
        public async Task <ResponseDatos> GetDatosExceptionRaisedWithUsing()
        {
            var output = new ResponseDatos();

            string _query = "select Id,Valor from DatosPrueba";

            using (var conn = new SqlConnection(_connectionString))
            {
                await conn.OpenAsync();

                var datos = await conn.QueryAsync <ObjetoDatosTest>(_query);

                throw new Exception("Testeando si cierra conexiones");


                output.Data = datos.ToList();
            }

            return(output);
        }
Example #3
0
        public async Task <ResponseDatos> GetDatosNotUsingButclosingConnection()
        {
            var    output = new ResponseDatos();
            string _query = "select Id,Valor from DatosPrueba";
            var    conn   = new SqlConnection(_connectionString);

            try
            {
                await conn.OpenAsync();

                var datos = await conn.QueryAsync <ObjetoDatosTest>(_query);

                output.Data = datos.ToList();
            }
            catch (Exception)
            {
                return(output);
            }
            finally
            {
                conn.Dispose();
            }
            return(output);
        }