Lets say I have the following code:
return (from p in repository.GetPostMedia() select p).ToList();
But in the values of object p, I want to inject a property calculated as follows:
MediaUrl = App.Resource["MediaPath"] + p.Id + "." + p.Ext;
PS. This code is located in the Service section of an ASP.NET MVC application. It is supposed to generate a url property and attach it to the returned object. If the controller is the best place to put this logic, how would I accomplish this with my code as follows:
public ActionResult PostMediaList(int postId)
{
var media = postService.GetMedia(); //the call to the code above.
return Json(media);
}
Media is generated from the LINQ to SQL in the repository. Also, i want to be able to change the path of where the media files are stored at a later date and just change something web project or service project only.