0
我有两个简单的模型: 书:如何通过第一个表与外部关键字从第二个表中获取字段?
public class Book
{
public int BookID { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public string Year { get; set; }
public string Publisher { get; set; }
public int GenreId { get; set; }
[ForeignKey("GenreId")]
public Genre Genre { get; set; }
}
和体裁
public class Genre
{
public Genre()
{
Books = new List<Book>();
}
public int GenreID { get; set; }
public string Name { get; set; }
public ICollection<Book> Books { get; set; }
}
随着法从ApiController我从表图书的所有数据。 如何获取javascript代码使用外键GenreId的表格类型的名称? 我想写点东西像book.Genre.Name,但它不能在JS工作
请向我们展示发送书籍的'Action'是如何返回的。它是否包含流派的细节?还包括执行请求的'js'。在问题中更新它,而不是评论 – Searching