Linq to datatable


I’m trying to use linq to datatable to fill scheduler but have circular reference error.
What I’m doing wrong?
Code for ProcessRequest:
DataTable dt = new DataTable();
dt.Columns.Add(“id”, System.Type.GetType(“System.Int32”));
dt.Columns.Add(“text”, System.Type.GetType(“System.String”));
dt.Columns.Add(“start_date”, System.Type.GetType(“System.DateTime”));
dt.Columns.Add(“end_date”, System.Type.GetType(“System.DateTime”));
DataColumn[] keys = new DataColumn[1];
keys[0] = dt.Columns[“id”];
dt.PrimaryKey = keys;

        DataRow row = dt.NewRow();
        row["id"] = 1;
        row["text"] = "TEST";
        row["start_date"] = DateTime.Now.Date;
        row["end_date"] = DateTime.Now.Date.AddDays(2);

        var results = from myRow in dt.AsEnumerable()
                      where myRow.Field<int>("id") == 1
                      select myRow;

        context.Response.ContentType = "text/json";// the data comes in JSON format
            new SchedulerAjaxData(results) //events for loading to scheduler


data renderer(SchedulerAjaxData) tries to serialize all public properties of the provided objects,
so it will fail if there is cross references. In case of DataRow it’s Table property.
You’ll have to select rows data into some intermediate class to be able render them, or you can render data manually

OK, thanks