这是我的控制器动作:
<EmployeeAuthorize()>
Function HRA_Table() As ActionResult
' get current employee's id
Dim db1 As EmployeeDbContext = New EmployeeDbContext
Dim user1 = db1.Tbl_Employees.Where(Function(e) e.Employee_EmailAddress = User.Identity.Name).Single()
Dim empId = user1.Employee_ID
Dim empSSN = user1.Employee_SSN
Dim hra = db.Tbl_HRAs.Where(Function(x) x.SSN = empSSN)
Return View(hra.ToList)
End Function
这是我的模型:
Public Class Tbl_HRA
<Key()> Public Property HRA_ID() As Integer
Public Property SSN() As String
Public Property Height() As Double
Public Property Weight() As Double
Public Property Nic_EE() As String
Public Property Nic_SP() As String
Public Property BMI() As Double
Public Property BP_S() As Double
Public Property BP_D() As Double
Public Property HDL() As Double
Public Property LDL() As Double
Public Property Tot_Chol() As Double
Public Property Continine() As String
Public Property Glucose() As Double
Public Property Waist() As Double
Public Property Hip() As Double
Public Property Triglycerides() As Double
Public Property A1C() As Double
Public Property LDL_HDL() As Double
End Class
这是我的看法:
@ModelType IEnumerable(Of GemcoBlog.Tbl_HRA)
@Code
Layout = Nothing
End Code
@For Each item In Model
@item.Height
Next
我得到的错误是:
'Tbl_HRA' 上的 'Height' 属性无法设置为 'String' 值。您必须将此属性设置为“Double”类型的非空值。
我似乎无法理解为什么会发生此错误。我尝试double
根据我阅读的一些文章将其更改为,但仍然无法正常工作!
谢谢你的帮助。