Hello:
I have the following piece of code to get a JSON string
public static string ReturnResults(Results results) { dynamic JObject = new JObject(); JObject.success = results.success; JObject.statuscode = results.statuscode; JObject.data = results.data; JObject.errormessage = results.errormessage; JObject.additionalmessage = results.additionalmessage; return JObject.ToString(); }
The "results.data" actually contains the results from the back end database table. When the data represents thousands of rows, I get out of memory exception.
Exception of type 'System.OutOfMemoryException' was thrown.
What's the efficient way to do this? Instead of a dynamic object, I can create a class and then serialize? Any help will be appreciated.