-1
ICollectionのコンテンツにアクセスしようとするとエラーが発生しました。 コードを次のように ビュー表示のICollectionデータにアクセスする
foreach (var carInfo in Model)
{
@carInfo.Id
@carInfo.Brand
......... ect.
foreach (var rentInfo in carInfo.RentInfo)
{
@rentInfo.RentDate
....... ect.
}
}
ビュートップ:
@model IEnumerable<TestApp.Models.Cars>
カーモデル:
foreach (var rentInfo in carInfo.RentInfo)
{
@rentInfo.RentDate
....... ect.
}
すべてWOR:
public class Cars
{
public int Id { get; set; }
public string CarPlateNumber { get; set; }
public string Brand { get; set; }
public string Fullname { get; set; }
public string Category { get; set; }
public int ReleaseDate { get; set; }
public int SeatCount { get; set; }
public string GearBox { get; set; }
public virtual ICollection<CarRent> RentInfo { get; set; }
}
を私はコードを削除した場合ksは問題ですが、なぜこのaprouchはうまくいかないのですか?
どのようなエラーが表示されますか? –
エラーは何ですか? '@foreach ...'を試し、変数にアクセスしている間に@を取り除いてください。 – Developer
リソースの読み込みに失敗しました:サーバーがステータス500(内部サーバーエラー)で応答しました –