return json c # .net core sql

0

I am testing with a console application . In it I query the database and would like to return a json file from the result.

Is it possible to return the query json without instantiating the object? how can I do this?

I tried converting the query return, but it did not work:

using (var connection = new SqlConnection("Server=4.4.4.4.;Database=aaaa;user id=aaaa;password=aaaaa"))
        {
            var cmd = new SqlCommand("SELECT * from depposvendas", connection);
            connection.Open();
            SqlDataReader reader = cmd.ExecuteReader();

    //Neste caso estou tentando converter com json.net para json o retorno do SqlDataReader
    //Sem ter que instanciar objeto
            string output = JsonConvert.SerializeObject(reader);
    Console.WriteLine("{0}",output);

        }
    
asked by anonymous 16.02.2018 / 20:19

0 answers