【发布时间】:2021-10-09 23:37:41
【问题描述】:
我有一个 Musico 模型和一个 Commune 模型, 我试着把他们俩都这样.. 我尝试使用 ** Tuple ** 等等,但我回到了这个基础
public class ComunaViewModel
{
public Comuna ComunaDTO { get; set; }
public Musico MusicoDTO { get; set; }
}
音乐
public class Musico
{
[Key]
public int Id { get; set; }
public string Nombre { get; set; }
public string Estilos { get; set; }
public int IdComuna { get; set; }
public string Email { get; set; }
社区
public class Comuna
{
[Key]
public int Id { get; set; }
public string Nombre { get; set; }
--
public async Task<IActionResult> Index()
{
return View(await _context.Musico.ToListAsync());
}
查看
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.MusicoDTO.Nombre)
</th>
<th>
@Html.DisplayNameFor(model => model.MusicoDTO.Estilos)
</th>
<th>
@Html.DisplayNameFor(model => model.ComunaDTO.Nombre)
----
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.MusicoDTO.Nombre)
</td>
<td>
@Html.DisplayFor(modelItem => item.MusicoDTO.Estilos)
</td>
<td>
@Html.DisplayFor(modelItem => item.ComunaDTO.Nombre)
【问题讨论】:
-
我投票结束这个问题,因为它不是英文的 - 请尝试Stack Overflow en español
-
请澄清您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: asp.net-core view model