asp.net-mvc - ASP.NET MVC 和实体框架问题
问题描述
我创建了一个小型学习项目来使用 Cdata 实用程序读取和写入 CRM。
我创建了一个模型、控制器和视图,但是在尝试查看索引页面时,我不断收到错误消息
new_accountactive 不是有效字段
我已经检查并仔细检查了 CRM 系统和 SQL 数据库。寻找有关我哪里出错的指导。
' GET: OriginatingAccounts (controller )
Function Index() As ActionResult
Private db As New DynamicsCRMContext
Dim _list = db.OriginatingAccounts.SqlQuery("SELECT id, new_accountserial, new_sun, new_sortcode, new_accountnumber, new_accountname
FROM new_oaccounts
WHERE new_accountactive = true").ToList
Return View(_list)
End Function
模型
Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel.DataAnnotations.Schema
<Table("new_oaccounts")>
Public Class OriginatingAccounts
<Key>
<Display(Name:="Account ID")>
Public Property Id As String
'<Display(Name:="Licence")>
'Public Property new_licenceid As String
<Display(Name:="Account Serial")>
Public Property new_accountserial As String
<Display(Name:="SUN")>
Public Property new_sun As String
<Display(Name:="Sort Code")>
Public Property new_sortcode As String
<Display(Name:="Account Number")>
Public Property new_accountnumber As String
<Display(Name:="Account Name")>
Public Property new_accountname As String
<Display(Name:="Active")>
Public Property new_accountactive As Nullable(Of Boolean)
<Display(Name:="Credit Account")>
Public Property new_creditingaccount As Boolean
<Display(Name:="Debit Account")>
Public Property new_debitingaccount As Boolean
<Display(Name:="SUN Validated")>
Public Property new_validated As Boolean
End Class
索引视图
ModelType IEnumerable(Of TestProject.OriginatingAccounts)
@Code
ViewData("Title") = "Index"
Layout = "~/Views/Shared/_Layout.vbhtml"
End Code
<h2>Originating Accounts</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<h4>Active Originating Accounts</h4>
<tr>
<th>
@Html.DisplayNameFor(Function(model) model.new_accountserial)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_sun)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_sortcode)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_accountnumber)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_accountname)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_accountactive)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_creditingaccount)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_debitingaccount)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.new_validated)
</th>
<th></th>
</tr>
@For Each item In (Model.Where(Function(w) w.new_validated = True))
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) item.new_accountserial)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_sun)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_sortcode)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_accountnumber)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_accountname)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_accountactive)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_creditingaccount)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_debitingaccount)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.new_validated)
</td>
<td>
@Html.ActionLink("Edit", "Edit", New With {.id = item.Id}) |
@Html.ActionLink("Details", "Details", New With {.id = item.Id}) |
@Html.ActionLink("Delete", "Delete", New With {.id = item.Id})
</td>
</tr>
Next
</table>
解决方案
推荐阅读
- java - 使用 ControllerService 的 NiFi 处理器 JUnit 测试
- android - 在 GKE 上运行 android 容器 - adb 未附加到设备
- php - Highchart不会将视图页面上的外部图像转换为pdf?
- c# - 如何在检查器菜单打开时处理 Outlook 自定义任务窗格的可见性
- azure - 如何使用 prependpath 在 azure-pipeline 中设置路径
- database - 按另一个表的内容过滤结果
- android - 在 android 中在哪里准确添加 Okhttp 和改造 proguard 规则?
- matlab - 如何清空一个单元格
- wordpress - 手机版首页出现logo怎么解决?
- spring-boot - 如何在 Spring Boot 中使用存储过程 MySQL?