我有两个类似的实体:
public class Movie
{
public int MovieID { get; set; }
public string Title { get; set; }
public List<Director> Directors { get; set; };
public int Year { get; set; }
}
public class Director
{
public int DirectorID { get; set; }
public string Name { get; set; }
public List<Movie> Movies { get; set; }
}
假设我想以导演的名义订购电影列表:
Movies.OrderBy (??? => ???)
我该怎么做?
提前致谢。
答案 0 :(得分:0)
var orderedMovies =
movies.OrderBy(movie =>
String.Join(",", movie.Directors
.OrderBy(dir => dir.Name)
.Select(dir => dir.Name)
)
);