一部のデータを取得しようとすると、このエラーが発生します。これが私がクエリしている方法です
using (_realtyContext = new realtydbEntities())
{
foreach (int yr in years)
{
var standard = (from feest in _realtyContext.FeeStandards
where feest.Year == yr && feest.FeeCategory.CategoryName == "PropertyFee"
select feest).SingleOrDefault();
var chargeItem = (from chrgItem in _realtyContext.PropertyFees
where chrgItem.FeeStandardID == standard.FeeStandardID
&& chrgItem.HousholdId == Householder.HouseholdID
select chrgItem).SingleOrDefault();
this._propertyFees.Add(chargeItem);
this._standards.Add(standard);
}
}
例外の詳細:System.NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていません。
エラーは2番目のクエリにあります。(varchargeItem)
このクエリはエラーをスローします:var ChargeItem = .. ..