C# EF无法将双精度转换为单精度
我收到一个错误: “无法将'EOIQote'上的'BomAmountTaxRate'属性设置为 “System.Double”值。必须将此属性设置为非空值 类型为“System.Single” db表架构是:C# EF无法将双精度转换为单精度,c#,entity-framework,types,C#,Entity Framework,Types,我收到一个错误: “无法将'EOIQote'上的'BomAmountTaxRate'属性设置为 “System.Double”值。必须将此属性设置为非空值 类型为“System.Single” db表架构是: QuoteID uniqueidentifier Unchecked SubmissionDate datetime Unchecked RfqID uniqueidentifier U
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
和EOIQOUTE 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误差完全没有任何意义。浮点=浮点:对吗?SQL中的浮点与.Net中的浮点不同。若您查看SqlDbType枚举表,就会发现SQLFLOAT等价于双精度类型 浮动->双精度。介于-1.79E+308到1.79E+308之间的浮点数 发件人: 在.Net中,浮点是System.Single类型的别名 -3.4×1038至+3.4×1038