实体框架 – 为什么“真实”和“浮动”映射到“单”而不是“双”
我在Model-First模式(= EDMX)中使用System.Data.SQLite 1.0.90与VS2013和EntityFramework 5.
我创建了一个包含一个表的新SQLite数据库: CREATE TABLE [..] [Test1integer] integer,[Test2int] int,[Test3smallint] smallint,[Test4tinyint] tinyint,[Test5bigint] bigint,[Test6money] money,[Test7float] float,[Test8real] real,[Test9decimal] decimal,[Test10numeric18_5] numeric(18,5),[..] 相关部分是Test7float和Test8real. 在从数据库…执行更新模型之后,EDMX现在包含: SSDL: <Property Name="Test1integer" Type="integer" /> <Property Name="Test2int" Type="int" /> <Property Name="Test3smallint" Type="smallint" /> <Property Name="Test4tinyint" Type="tinyint" /> <Property Name="Test5bigint" Type="integer" /> <Property Name="Test6money" Type="decimal" Precision="53" Scale="0" /> <Property Name="Test7float" Type="real" /> <Property Name="Test8real" Type="real" /> <Property Name="Test9decimal" Type="decimal" Precision="53" Scale="0" /> <Property Name="Test10numeric18_5" Type="decimal" Precision="18" Scale="5" /> 相关部分是Test7float和Test8real. CSDL: <Property Name="Test1integer" Type="Int64" /> <Property Name="Test2int" Type="Int32" /> <Property Name="Test3smallint" Type="Int16" /> <Property Name="Test4tinyint" Type="Byte" /> <Property Name="Test5bigint" Type="Int64" /> <Property Name="Test6money" Type="Decimal" Precision="53" Scale="0" /> <Property Name="Test7float" Type="Single" /> <Property Name="Test8real" Type="Single" /> <Property Name="Test9decimal" Type="Decimal" Precision="53" Scale="0" /> <Property Name="Test10numeric18_5" Type="Decimal" Precision="18" Scale="5" /> 相关部分是Test7float和Test8real. 问题 Test7float错误地变成了“真实的”“单一” – 设计师也不允许在这里“双”. SQLite3文档(http://www.sqlite.org/datatype3.html)清楚地表示“真实”是一个8字节的IEEE浮点数,“浮点”只是“真实”的同义词 – 因此在每种情况下,“双”(8字节)应优先于“单”(4字节). 我做错事了还是我误会了什么?如果没有:出现什么问题,怎么解决? 我应该为此创建错误报告吗? 看起来像映射驱动程序中的错误.用于声明列的类型仅用于亲和性(您可以声明一个列为float,如果需要,则在其中存储blob). 在报告表结构时,SQLite仅返回用于创建其字段的SQL定义(如果适用,则更改它们). 因此,您的驱动程序只能使用“float”作为字段类型,并且可能通过一些通用代码将其映射到“single”,这可能并没有写入SQLite(或者为了SQLite而被覆盖). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |