显示其他表格中的数据

时间:2017-08-22 17:59:19

标签: asp.net sql-server

对不起初学者的问题。我想问你关于ms sql和asp.net的问题。我有2张桌子 - 专辑和艺术家。我想在点击艺术家详情后显示所有专辑。你能告诉我如何在Artits的显示屏上显示标题吗?请从我的应用程序中找到以下型号

    public class Artist
{
    public int ArtistId { get; set; }
    public string Name { get; set; }
    public ICollection<Album> Albums { 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 decimal Price { get; set; }
    public string AlbumArtUrl { get; set; }
    public Genre Genre { get; set; }
    public Artist Artist { get; set; }
    public DateTime ReleaseDate { get; set; }
}

在views / artists / details.cshtml下面

@model AlbumStore.Models.Artist

@{
ViewData["Title"] = "Details";
}

<h2>Details</h2>

<div>
<h4>Artist</h4>
<hr />
<dl class="dl-horizontal">
    <dt>
        @Html.DisplayNameFor(model => model.Name)
    </dt>
    <dd>
        @Html.DisplayFor(model => model.Name)
    </dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.ArtistId">Edit</a> |
<a asp-action="Index">Back to List</a>
</div>

0 个答案:

没有答案