You can sort the returned anonymous type, just not as strong as the typed one. I use this method to create json serializable types.
Returns the type of "object" in your data model class:
public object TRFLIST() { var info = from trfTable in Company.TRFs join exusrTable in MasterData.ex_users on trfTable.P_ID equals exusrTable.EXUSER select new { trfTable.REQ_NO, trfTable.REQ_DATE, exusrTable.USER_NAME, exusrTable.USER_LNAME, trfTable.FROM_DT, <snipped> }; return info; }
Then call it from your controller like this (in this example I use it to return JsonResult):
public JsonResult() { var myAnonTRFLIST = dataClassInstance.TRFLIST(); return Json(myAnonTRFLIST, JsonRequestBehavior.Allowget); }
You can also explore the use of the new dynamic type if you are in 4.0 ...
-UPDATE: I just tried this and it worked perfectly -
Returns the type of "object" in your data model class:
public List<object> TRFLIST() { var info = from trfTable in Company.TRFs join exusrTable in MasterData.ex_users on trfTable.P_ID equals exusrTable.EXUSER select new { trfTable.REQ_NO, trfTable.REQ_DATE, exusrTable.USER_NAME, exusrTable.USER_LNAME, trfTable.FROM_DT, <snipped> }; return info.ToList<object>(); } public JsonResult() { dynamic myAnonTRFLIST = dataClassInstance.TRFLIST(); string test = myAnonTRFLIST[0].USER_NAME; <Do something with Test> return Json(myAnonTRFLIST, JsonRequestBehavior.Allowget); }
source share