Looking at the above example I'm wondering how I can convert the requestedClass which is of type object into an array for me to read from.
[HttpGet]
public object Get(string table, string columns, int id)
{
var splitColumns = columns.Split(',');
var t = new propertyModel()
{
gallery = _db.PROPERTYGALLERies.Where(p => p.propertyId == id).ToList(),
property = _db.PROPERTies.SingleOrDefault(p => p.id == id)
};
var requestedClass = t.GetType().GetProperty(table.ToLower()).GetValue(t, null);
var returnArray = new Dictionary<string, List<string>>();
var requestArray = new List<string>();
foreach (var column in splitColumns)
{
foreach (var field in StringProperties(requestedClass, column))
{
requestArray.Add(field.Value);
}
}
returnArray.Add(table, requestArray);
return Json(returnArray, JsonRequestBehavior.AllowGet);
}
public IEnumerable<KeyValuePair<string, string>> StringProperties(object obj, string column)
{
return from p in obj.GetType().GetProperties()
where p.Name == column
select new KeyValuePair<string, string>(p.Name, Convert.ToString(p.GetValue(obj)));
}

requestedClass.GetType()?requestedClass