We created the WebAPI for querying an Oracle database. The query returns results that are very huge. We cannot go for pagination as the client application requires the entire result in one call. There was an issue when there is a huge amount of data it throws Out of memory exception. As suggested in other forums I tried to add below tags in the web.config also as suggested in link
<requestLimits maxAllowedContentLength="2147483647" />
(this was placed inside
<system.webServer><security><requestFiltering>
and
<httpRuntime targetFramework="4.6.1" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
Placed inside
<system.web>
But after adding, tried calling the API it keeps loading forever(waited for almost 1hour) yhen again it threw the same out of System.OutofMemoryException. Can anyone please help me with this as this is my first Web API. We cannot create stored procedure for this because the database we just have read access
public HttpResponseMessage Getdetails([FromUri] string[] id)
{
string connStr = ConfigurationManager.ConnectionStrings["ProDataConnection"].ConnectionString;
using (OracleConnection dbconn = new OracleConnection(connStr))
{
var inconditions = id.Distinct().ToArray();
var srtcon = string.Join(",", inconditions);
DataSet userDataset = new DataSet();
var strQuery = @"SELECT * from STCD_PRIO_CATEGORY where STPR_STUDY.STD_REF IN(" + srtcon + ")";
using (OracleCommand selectCommand = new OracleCommand(strQuery, dbconn))
{
using (OracleDataAdapter adapter = new OracleDataAdapter(selectCommand))
{
DataTable selectResults = new DataTable();
adapter.Fill(selectResults);
var returnObject = new { data = selectResults };
var response = Request.CreateResponse(HttpStatusCode.OK, returnObject, MediaTypeHeaderValue.Parse("application/json"));
ContentDispositionHeaderValue contentDisposition = null;
if (ContentDispositionHeaderValue.TryParse("inline; filename=ProvantisStudyData.json", out contentDisposition))
{
response.Content.Headers.ContentDisposition = contentDisposition;
}
return response;
I even tried to add Breakpoints and just the adapter.Fill(selectResults) takes longer time. If the row count was around 45,000 it returns result without any issue. The ID I tried is suppose to return 600,000 rows is where we get the memory exception. Can anyone please help me with this.