switch (searchBy)
{
case "byName" :
model = db.Movies.Where(m => m.Name.StartsWith(searchText)).ToList();
break;
case "byActor":
model = db.Movies.Select(m => m.Actors.ForEach(x => x.Name.StartsWith(searchText))).ToList();
break;
}
public class Actor
{
public Actor()
{
Movies = new List<Movie>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual List<Movie> Movies { get; set; }
}
public class Movie
{
public Movie()
{
Genres = new List<Genre>();
Actors = new List<Actor>();
}
public int Id { get; set; }
public string Name { get; set; }
public int Year { get; set; }
public virtual Country Country { get; set; }
public virtual List<Genre> Genres { get; set; }
public virtual List<Actor> Actors { get; set; }
}
Всем привет, недавно начал осваивать .net mvc - возник вопрос выборки данных из БД. Нужно сделать выборку всех фильмов в которых есть соответствующие запросу актеры (input text value). Причем имя актера не должно строго соответствовать данным в базе (StartWith).