I am using Subsonic ORM by Rob Connery with Backbone.Js to build javascript single page demonstration application. in one of the service end point there is a contract that send all the records existing in the data source like below
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public TaskCollection GetAllTasks()
{
TaskCollection coll = new TaskCollection();
coll.Load();
return coll;
}
but seems that each Task in the collection is polluted with loads of properties that are required only on server side. This is the JSON returned on request
[{
"__type": "DAL.Task",
"Taskid": 1,
"Taskname": "welcome to india",
"Createdon": "\/Date(1334591056903)\/",
"Modifiedon": "\/Date(1334591056903)\/",
"ValidateWhenSaving": true,
"DirtyColumns": [],
"IsLoaded": true,
"IsNew": false,
"IsDirty": false,
"TableName": "task",
"ProviderName": null,
"NullExceptionMessage": "{0} requires a value",
"InvalidTypeExceptionMessage": "{0} is not a valid {1}",
"LengthExceptionMessage": "{0} exceeds the maximum length of {1}",
"Errors": []
}]
all i require is CreatedOn,ModifiedOn and TaskName, TaskId . How do i make sure only these are sent down the wire using SubSonic ORM
Here’s a couple of ideas…
Use the viewmodel to autoselect the properties:
Use an anonymous type