字段類型就是金錢,如果我把一個「0」或「1」在場上我得到這個錯誤:sqlite的實體框架 - 錯誤:「指定的轉換無效」
System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.InvalidCastException: Specified cast is not valid.
at System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
at System.Data.SQLite.SQLiteDataReader.GetBoolean(Int32 i)
--- End of inner exception stack trace ---
這是從模型設計:
<Property Name="Amount" Type="decimal" Precision="53" />
====
<EdmScalarPropertyAttribute(EntityKeyProperty:=False, IsNullable:=True)>
<DataMemberAttribute()>
Public Property Amount() As Nullable(Of Global.System.Decimal)
Get
Return _Amount
End Get
Set(ByVal value As Nullable(Of Global.System.Decimal))
OnAmountChanging(Value)
ReportPropertyChanging("Amount")
_Amount = StructuralObject.SetValidValue(value)
ReportPropertyChanged("Amount")
OnAmountChanged()
End Set
End Property
Private _Amount As Nullable(Of Global.System.Decimal)
Private Partial Sub OnAmountChanging(value As Nullable(Of Global.System.Decimal))
End Sub
Private Partial Sub OnAmountChanged()
End Sub
代碼獲取錯誤:
Dim Query = From c In EnData.Transactions Where c.TranID = 660 ' this tran is the amount 0
For Each tran In Query 'Error here
Next
向我們顯示代碼。 –
我添加了一些代碼,這是你在找什麼? – Ezi
你能向我們展示你設置金額的代碼嗎? – arviman