Where is the best place to call the .tolist(); inside my controller classes or inside my model repository classes
- by john G
I have the following action method, inside my asp.net mvc web application:-
public JsonResult LoadZoneByDataCenter(string id)
{
var zonelist = repository.getrealtedzone(Convert.ToInt32(id)).ToList();
//code goes here
Which calls the following model repository method:-
public IQueryable<Zone> getrealtedzone(int? dcid) {
return tms.Zones.Where(a=> a.DataCenterID == dcid || dcid == null);
}
Currently I am calling the .tolist() which will interpret the Database from my action method, but my question is where is the best place to call the .tolist() inside the controller or inside the model classes and why ?
thanks