使用EF4将Int32转换为Oracle号(5) [英] Convert Int32 to Oracle number(5) with EF4

查看:716
本文介绍了使用EF4将Int32转换为Oracle号(5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是一个oracle 10g数据库的EF 4(数据库第一,模型完全从它生成),我有一个字段有问题。

I am using EF 4 (database first, model fully generated from it) with an oracle 10g database and I have a problem with one field.

我的字段在我的数据库中定义为 NUMBER(5)。在我的模型中,EF定义为 short
我的问题是,我有一些值大于32,767(最多一个短)
我发现这篇文章:实体框架生成短而不是int 。我按照说明操作,我的模型现在包含Int32值。

My field is defined as a NUMBER(5) in my database. In my model, EF has defined it as a short. My problem is that i have some values that are greater than 32,767 (max of a short) I found this post : Entity Framework generates short instead of int. I follow the instruction and it works, my model contain now Int32 values.

但我有一个新问题:

Error 2019: Member Mapping specified is not valid. The type 'Edm.Int32[Nullable=True,DefaultValue=]' of member 'XX' in type 'Model.XXX' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=5,Scale=0]' of member 'XX' in type 'Model.Store.XXX'.

此错误始终显示在Visual Studio的错误列表选项卡中。但是,构建成功,它的一半工作:

This error is always show in the Error List tab of Visual Studio. However, the build success, and it half works:


  • 读取数据库中的值

  • 写一个值不工作:99999转换成-31073(见编辑)

有解决方案,方法?

BTW,有没有办法告诉实体使用int32的oracle INTEGER字段?默认使用十进制。

BTW, is there any way to tell entity to use int32 for oracle INTEGER fields ? It use decimal by default.

编辑

我发现为什么我的价值是-31073。我忘了这一行:

While debuging step by step, I found why my value was -31073. I forgot this line :

dao.Value = (short)dto.Value;

我的两个值是int,但隐含的转换是原点。

My two values were int, but the implicit conversion in short was the origin.

推荐答案

我找到了如何清除错误。

I found how to remove the error.

我编辑了xml中的edmx文件模式,在ssdl部分找到我的字段:

I edited the edmx file in xml mode, found my field in the ssdl section :

<Property Name="SIT_INSEE" Type="number" Precision="5" />

我删除了 Precision =5并且警告消失。

I removed the Precision="5" and the warning disappeared.

这篇关于使用EF4将Int32转换为Oracle号(5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆