public ActionResult Index(string search = "") { var metaTypes = string.IsNullOrWhiteSpace(search) ? _metaRepository.GetAll() : _metaRepository.FindMetaTypes(search); var model = metaTypes.Select(metaType => new MetaViewModel() { Id = metaType.Id, Name = metaType.Name }).ToList(); ViewBag.SearchString = search; return(View(model)); }