我收到错误:
“'EoiQuote'上的'BomAmountTaxRate'属性无法设置为a 'System.Double'值。您必须将此属性设置为非null值 类型'System.Single'。 “
db表架构是:
QuoteID uniqueidentifier Unchecked
SubmissionDate datetime Unchecked
RfqID uniqueidentifier Unchecked
SupplierID uniqueidentifier Unchecked
SupplierRef nvarchar(50) Checked
BomAmountExTax decimal(18, 2) Unchecked
BomAmountCurrencyID int Unchecked
BomAmountTaxRate float Unchecked
BomTaxAmount decimal(18, 0) Unchecked
FreightAmountExTax decimal(18, 0) Unchecked
FreightAmountCurrencyID int Unchecked
FreightAmountTaxRate float Unchecked
FreightTaxAmount decimal(18, 0) Unchecked
FreeFormParticulars text Checked
AvailabilityOpeningDate datetime Checked
AvailabilityClosingDate datetime Checked
Status int Unchecked
TransactionID uniqueidentifier Checked
Quantity int Unchecked
LastModified datetime Unchecked
ReviewedDate datetime Checked
RevisionID tinyint Checked
EoiQuote POCO如下:
public class EoiQuote
{
public Guid QuoteID { get; set; }
public DateTime SubmissionDate { get; set; }
public Guid RfqID { get; set; }
public Guid SupplierID { get; set; }
public string SupplierRef { get; set; }
public decimal BomAmountExTax { get; set; }
public int BomAmountCurrencyID { get; set; }
public float BomAmountTaxRate { get; set; }
public decimal BomTaxAmount { get; set; }
public decimal FreightAmountExTax { get; set; }
public int FreightAmountCurrencyID { get; set; }
public float FreightAmountTaxRate { get; set; }
public decimal FreightTaxAmount { get; set; }
public string FreeFormParticulars { get; set; }
public DateTime AvailabilityOpeningDate { get; set; }
public DateTime AvailabilityClosingDate { get; set; }
public int Status { get; set; }
public Guid TransactionID { get; set; }
public int Quantity { get; set; }
public DateTime LastModified { get; set; }
public EoiQuote()
{
}
}
因此,正常情况下,EF错误绝对没有任何意义。 float = float:对吗?
答案 0 :(得分:24)
SQL中的float与.Net中的float不同。如果查看SqlDbType枚举表,您会发现SQL float等效于double类型。
浮子>双。浮点数在-1.79E +308到1.79E +308的范围内。
来自C# Reference:
在.Net中,float是System.Single类型的别名。
-3.4×10 38 至+3.4×10 38