I have the following code:
GenericManager gm = new GenericManager();
DataSet ds = new DataSet();
ds = gm.ExecuteQuery(gr.TableName, gr.ColumnName, gr.WhereClause);
return Json(ds, JsonRequestBehavior.AllowGet);
In which ExecuteQuery
is the method of the class GenericManager
which will return dataset and that dataset is saved into the object ds
.
I am implementing a functionality that will fetch data from different table everytime. It means that to populate the DataSet
i am passing the name of the table of which data would be populated into the DataSet
. So, I have to pass the dataset from Json everytime because i am not sure about the columns returned by the query.
If I try to return the dataset through Json then the following exception is thrown:
A circular reference was detected while serializing an object of type 'System.Globalization.CultureInfo'.
So, i am looking for the way that will pass my DataSet
to Json
.
The following code that i have already tried is:
return Json(ds.Tables[0].Rows[0], JsonRequestBehavior.AllowGet);
Also,
return Json(ds.Tables.AsQueryable(), JsonRequestBehavior.AllowGet);
Please help to fix it, as i have to submit it by the end of the day