/// <summary> /// Created IActionResult object that contains the processed response result. /// </summary> /// <param name="pipe">Sql Pipe that will be used to fetch the data.</param> /// <returns>ContentResult with the data processed by request.</returns> public virtual async Task <IActionResult> GetResult(TSqlCommand mapper) { IActionResult result = null; try { var json = await mapper .Sql(cmd) .GetString() .ConfigureAwait(false); result = new ContentResult() { Content = json, StatusCode = StatusCodes.Status200OK, ContentType = "application/json" }; } catch (Exception ex) { result = new ContentResult() { Content = ex.Message, StatusCode = StatusCodes.Status500InternalServerError }; } return(result); }
public override async Task Process(TSqlCommand pipe) { if (this.countOnly) { await pipe.Sql(cmd).Stream(response.Body, "-1"); } else if (metadata == Metadata.NONE) { response.ContentType = "application/json;odata.metadata=none;odata=nometadata"; await pipe .Sql(cmd) .OnError(async e => await ReturnClientError(response, e)) .Stream(response.Body, IsSingletonResponse ? "{}" : "{\"value\":[]}"); } else if (metadata == Metadata.MINIMAL) { response.ContentType = "application/json;odata.metadata=minimal"; var header = "{\"@odata.context\":\"" + this.metadataUrl + "#" + this.tableSpec.Name + "\",\"value\":"; await pipe .Sql(cmd) .OnError(async e => await ReturnClientError(response, e)) .Stream(response.Body, new Options() { Prefix = header, DefaultOutput = "[]", Suffix = "}" }); } else { await ReturnClientError(response, new InvalidOperationException("Cannot generate response for metadata type: " + metadata)); } }
/// <summary> /// Process the current request and returns result using the target database. /// </summary> /// <param name="pipe">Sql Pipe that will be used to fetch the data.</param> /// <returns>Async task that will stream results.</returns> public virtual async Task Process(TSqlCommand pipe) { response.ContentType = "application/json"; await pipe.Sql(cmd) .OnError(async e => await ReturnClientError(response, e)) .Stream(response.Body, IsSingletonResponse?"{}":"[]") .ConfigureAwait(false); }
public override async Task Process(TSqlCommand pipe) { response.ContentType = "application/json"; var header = $@"{{ ""draw"":""{draw}"", ""recordsTotal"":""{start + length + 1}"", ""recordsFiltered"":""{start + length + 1}"", ""data"":"; await pipe .Sql(cmd) .Stream(response.Body, new Options() { Prefix = header, DefaultOutput = "[]", Suffix = "}" }); }
public RestApiController(TSqlCommand command, ILogger <RestApiController> logger) { this.DbCommand = command; this._logger = logger; }
public SysODataController(TSqlCommand command) : base(command) { }
public override async Task Process(TSqlCommand pipe) { await ReturnClientError(response, ex); }
public ODataController(TSqlCommand command) { this.DbCommand = command; }
public DapperRestApiController(TSqlCommand queryService, ILogger <RestApiController> logger) { this.queryService = queryService; this._logger = logger; }