0
我在ASP.Net和MVC5編程是新的,其實我有一個問題,我有這班「學生」:如何訪問列表對象的ASP.Net Web服務
namespace Project.Entities.Models
{
public partial class Student : BaseEntity
{
public string FirstName { get; set; }
public string LastName { get; set; }
[ForeignKey("ClassId")]
public virtual Class Class { get; set; }
public Int64 ClassId { get; set; }
[ForeignKey("ImageId")]
public virtual Image Image { get; set; }
public Int64 ImageId { get; set; }
public virtual List<Mark> Marks { get; set; }
public virtual List<Punishment> Punishments { get; set; }
public Student()
{
Marks = new List<Mark>();
Punishments = new List<Punishment>();
}
}
類「馬克」:
namespace SMA.Entities.Models
{
public partial class Mark : BaseEntity
{
public int Score { get; set; }
public string Note { get; set; }
[ForeignKey("StudentId")]
public virtual Student Student { get; set; }
public Int64 StudentId { get; set; }
}
}
我想每個學生的標誌,但我不知道怎麼回事, 這是我在JSON結果得到:
[
{
FirstName: "Student ",
LastName: "1",
Class: null,
ClassId: 1,
Image: null,
ImageId: 1,
Marks: [ ],
Punishments: [ ],
Id: 1,
ObjectState: 0
},
{
FirstName: "Student ",
LastName: "2",
Class: null,
ClassId: 2,
Image: null,
ImageId: 2,
Marks: [ ],
Punishments: [ ],
Id: 2,
ObjectState: 0
}
]
所以請你有任何想法,我怎麼能訪問每個學生的標記數據 感謝幫助
請添加你的控制器代碼。 –