0
私はMvcMusicStoreをベースとして使用しているサイトをやっています。MVC3 - Includeを使用してdbクエリをソート
特定のジャンルのすべてのアルバムを取得し、アーティスト名で注文したいと考えています。私は実際にアーティスト名で注文する方法を理解することはできません。
マイモデル:私はアーティスト名で結果を注文することができますどのように
public partial class Genre { public int GenreId { get; set; } public string Name { get; set; } public string Description { get; set; } public ICollection Albums { get; set; } public ICollection Artists { get; set; } } public class Artist { public int ArtistId { get; set; } public string Name { get; set; } } public class Album { public int AlbumId { get; set; } public int GenreId { get; set; } public int ArtistId { get; set; } public string Title { get; set; } public string Price { get; set; } public string AlbumArtUrl { get; set; } public string Description { get; set; } public virtual Genre Genre { get; set; } public virtual Artist Artist { get; set; } } My Controller: public ActionResult Index(string genre = "CD/LP") { var genreModel = storeDb.Genres.Include("Albums").Include("Artists") .Where(g => g.Name == genre).FirstOrDefault(); return View(genreModel); }
?
恐ろしい!あなたは私の一日を救った! –