我有一个C# MVC Model
如下;
public class MyModel
{
...
public IEnumerable<MyModel> allDetails { get; set; }
public int age { set; get; }
public string gender { set; get; }
public int schoolid { set; get; }
...
}
现在想从中检索数据allDetails
。我该怎么做 ?
在controller
;
model.allDetails = MyDetails.getAllDetails(); // Saves all details in the Model
现在我如何从中age, gender and school
检索model
;我的方法如下(但它不起作用)
model.allDetails.age; // This doesn't work