public async Task <IActionResult> Search([FromBody] SearchData searchData) { await using var connection = new SqlConnection(_connectionString); var result = await connection.QueryAsync <dynamic>(searchData.Query); return(Ok(new SearchResult { Metadata = await GetQueryMetadata(searchData, connection), Data = result.ToList() })); }
public async Task <IActionResult> TestSearch([FromBody] SearchData searchData) { var url = "https://localhost:44333/test/search"; using HttpClient client = new HttpClient(); var response = await client.PostDataAsync(url, searchData); if (response != null) { var jsonString = await response.Content.ReadAsStringAsync(); //DataSet data = JsonConvert.DeserializeObject<DataSet>(jsonString); //DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsonString, (typeof(DataTable))); var data = Tabulate(jsonString); return(Ok(data)); } return(BadRequest()); }
private static async Task <IEnumerable <dynamic> > GetQueryMetadata(SearchData searchData, SqlConnection connection) { return(await connection.QueryAsync("sp_describe_first_result_set", new { tsql = searchData.Query }, commandType : CommandType.StoredProcedure)); }
public async Task <IActionResult> TestSearch([FromBody] SearchData searchData) { return(Ok()); }