我正在尝试使用 C# Entity Framework 中的 Oracle.ManagedDataAccess 从 oracle 数据库中获取数据。但是,当oracle中的数据类型是数字,并且值为6.17880949622285E-11时,我得到了错误。这是错误消息
{
"ClassName": "System.InvalidCastException",
"Message": "Specified cast is not valid.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at Oracle.ManagedDataAccess.Client.OracleDataReader.GetDecimal(Int32 i)\r\n at Oracle.ManagedDataAccess.Client.OracleDataReader.GetValue(Int32 i)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)\r\n at lambda_method(Closure , Shaper )\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)\r\n at lambda_method(Closure , Shaper )\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at WebApiService.Master.Facul.FaculService.FetchAllProportionalByParameters(FaculModel faculSearch) in D:\\Projects\\Reins\\WebApiService\\Master\\Facul\\FaculService.cs:line 176\r\n at PKBL.Controllers.Master.FaculController.FetchAllProportionalByParameters(FaculModel faculSearch) in D:\\Projects\\Reins\\REINS\\Controllers\\Master\\FaculController.cs:line 74",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nGetDecimal\nOracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342\nOracle.ManagedDataAccess.Client.OracleDataReader\nSystem.Decimal GetDecimal(Int32)",
"HResult": -2147467262,
"Source": "Oracle.ManagedDataAccess",
"WatsonBuckets": null
}
我已经调查过了,我发现问题出在数据类型上。顺便说一句,我首先使用代码,这是我的 EF 类
public class MasterFacul : BaseEntityModel
{
....
public decimal? FacWrtShr { get; set; } <- **The Problem**
我试图增加精度,但没有奏效。谁能帮我?