![](/img/trans.png)
[英]could not be set to a 'System.Decimal' value. You must set this property to a non-null value of type 'System.Double'
[英]How to get rid of 'property could not be set to a double value, you must set this property to a non-null value of type decimal'
我正在嘗試讓函數導入正常工作。 EF調用我的存儲過程,但結果有一個我不明白的內部異常:
var result = context.SomeFunctionImport();
我明白了:
'SomeClass'上的'Cnt'屬性無法設置為'Double'值。 您必須將此屬性設置為“Decimal”類型的非null值。
這是SomeClass
上的Cnt
屬性:
[DataMember]
public Nullable<decimal> Cnt
{
get { return _cnt; }
set
{
if (_cnt != value)
{
OnComplexPropertyChanging();
_cnt = value;
OnPropertyChanged("Cnt");
}
}
}
private Nullable<decimal> _cnt;
我認為這個字段是數據庫表中的float類型。 所以你需要將它設置為雙倍? 如果此字段可以為空或以其他方式使用double
public double? field_name {get; set}
// or
public double field_name {get; set}
它對我有用
你需要像這樣定義: public decimal Cnt
發現了這個問題。 在舍入操作后,我的存儲過程在Cnt上丟失了一個強制轉換。
我有這個問題,我的問題是在DB上,類型是真實的,在EF類中聲明為十進制。 我剛剛將DB類型更改為real並解決了問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.