I am attempting to populate my ViewData with ONLY specific DB Entity Sets in my ASP.NET MVC 4 project. Below is what I have so far, but how do I write this "if" statment to accomplish this?
public PartialViewResult _GetforSelectedStatus(string TargetName)
{
_selectedJobDB = new IntegrationDBEntities();
foreach (Job j in _selectedJobDB.Jobs)
{
if (j.Request.TargetName == TargetName)
{
//I need to add the Job that meets the above "if" requirment to the ViewData here....
}
}
}
Normally I have been then sending the ViewData Model to the partial view as below, but I don't think this will work since I am not wanting to send the whole model:
ViewData.Model = _selectedJobDb.Jobs.ToList();
return PartialView();
How do I add ONLY specific DB Entity Sets to the ViewData and send this to the PartialView?
ViewData.Model = _selectedJobDb.Jobs.Where(j => j.Request.TargetName == TargetName).ToList();