提问人:Musfirah Hamid 提问时间:9/7/2023 最后编辑:marc_sMusfirah Hamid 更新时间:9/7/2023 访问量:18
VM_AccountHistory列表为 null。对象引用未设置为 c 中对象的实例#
VM_AccountHistory list is null. Object reference not set to an instance of an object in c#
问:
public ActionResult ReportWrongCompare(VM_ReportComparison model, AccountTypes accountType)
{
model.SelectedAccountType = accountType;
var accountHistoryData = new VM_AccountHistory().FindByAttribute(c => c.AccountHistoryID == model.Id);
if (accountHistoryData != null)
{
model.CustomerAccount.RMO_AccountHistory = accountHistoryData;
}
return View("_ReportWrongCompare", _AutoDisputeEnterPriseLayout, model);
}
accountHistoryData
引发错误。
问题出在这行代码上吗?
new VM_AccountHistory().FindByAttribute(c => c.AccountHistoryID == model.Id)
我希望获得数据。
@if (Model.SelectedAccountType == AccountTypes.AccountHistory
&& Model.CustomerAccount.RMO_AccountHistory != null)
{
<!-- Display fields for AccountHistory -->
<table>
<thead>
<tr>
<th>Attributes</th>
<th>Confirmed Report</th>
<th>UnConfirmed Report</th>
</tr>
</thead>
<tbody>
@foreach (var historyAccount in Model.CustomerAccount.RMO_AccountHistory)
{
<tr>
<td>Account Name</td>
<td>@historyAccount.AccountName</td>
</tr>
}
</tbody>
</table>
}
答: 暂无答案
评论