【问题标题】:LINQ-SQL keep requiring money column to be of type Single, even though it already isLINQ-SQL 一直要求 money 列的类型为 Single,即使它已经是
【发布时间】:2013-06-06 13:37:25
【问题描述】:

我得到的错误是这样的:

The 'SalesValue' property on 'ItemSale' could not be set to a 'Decimal' value. 
You must set this property to a non-null value of type 'Single'.

但我已经这样做了:

[Table("ItemSales")]
public class ItemSale {
    [Key]
    public int ID { get; set; }
    ....
    public Single SalesValue { get; set; }
}

这是我的 LINQ,很简单:

            from x in database.ItemSales
            select x

我首先使用实体​​框架代码

我该如何解决这个问题?

【问题讨论】:

  • 这是代码优先吗?也许您的数据库已经存在并且数据类型不同
  • 是的,这是 EF-Code First。数据库使用此处定义的“ItemSale”对象,因此不会有什么不同。

标签: c# linq-to-sql ef-code-first


【解决方案1】:

您检查过列类型的精度吗?这是我曾经遇到的一个错误,据我所知,与你的非常相似。 据我记得,精度必须为 2,但有另一个值。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-03
  • 2021-04-05
  • 2014-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多