I got an error while I try to get to my view. I've tried without IEnumerable but it doesn't work as well.
Error: MVC: The model item passed into the dictionary is of type System.Int32 while this dictionary requires a type model element System.Collections.Generic.IEnumerable`1[Cinema.Models.Video].
@model IEnumerable<Cinema.Models.Video>
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
My controller
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Search()
{
CinemaEntities db = new CinemaEntities();
return View(db.SearchVideo(""));
}
[HttpPost]
public ActionResult Search(string VideoName)
{
CinemaEntities db = new CinemaEntities();
return View(db.SearchVideo(VideoName));
}
}
My SearchVideo
public virtual ObjectResult<Video_SearchVideo_Result1> Video_SearchVideo(string videoName)
{
var videoNameParameter = videoName != null ?
new ObjectParameter("VideoName", videoName) :
new ObjectParameter("VideoName", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Video_SearchVideo_Result1>("Video_SearchVideo", videoNameParameter);
}
public virtual int SearchVideo(string videoName)
{
var videoNameParameter = videoName != null ?
new ObjectParameter("VideoName", videoName) :
new ObjectParameter("VideoName", typeof(string));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SearchVideo", videoNameParameter);
}