I am using the Memory Management while returning the data like below.
private DataSet ReturnDs()
{
using (DataSet ds = new DataSet())
{
return ds;
}
}
Query – Is there any issue in placing the ‘Using’ Statement while returning the data? I am Still getting the complete schema as well as the data in the receiving function?
This is definitely a wrong pattern. The only reason that it is working for you now is that
DataSet.Dispose()is actually a dummy.If you replace the DataSet with for instance an Enitity framework DbContext then you would not see any data in the calling function.