string jsonResultado = await Clases.AccesoDatos.JsonData("SELECT * FROM vistatransacciones for json path, ROOT('product.json')"); where method jsonData is: public static async Task<string> JsonData(string SQL) { string json = ""; using (SqlConnection con = new SqlConnection(cadenaConexion)) { SqlCommand cmd = new SqlCommand(SQL, con); await con.OpenAsync(); SqlDataReader dr = await cmd.ExecuteReaderAsync(); if (dr.HasRows) { DataTable jsondt = dr.GetSchemaTable(); json= JsonConvert.SerializeObject(jsondt); } dr.Close(); } return json; }
{"Product.json": [{"idRegistro":1, "idUsuario":"1", "FechaRegistro":"2023-01-18T11:29:23.030", .....
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)