-
Notifications
You must be signed in to change notification settings - Fork 0
[Netcore] 复杂数据模型
Jinxin Chen edited this page Dec 11, 2019
·
1 revision
public class Article
{
public string CategoryId { get; set; }
public Category Category { get; set; }
}
ViewData["CategoryId"] = new SelectList(_dbContext.Category.ToList(), "Id", "CategoryName");
<select asp-for="CategoryId" class="form-control" asp-items="ViewBag.CategoryId"></select>
var article = await _dbContext.Article.Include(c => c.Category).SingleOrDefaultAsync(m => m.Id == key);