我正在尝试对FirstOrDefault()
对象集进行查询,并引发了一个奇怪的异常:
我的代码:
private RecordObject GetRecordByID(int recID)
{
return _objectSet.FirstOrDefault(rec => rec.ID == recID);
}
异常消息:
输入字符串的格式不正确
InnerException
一片空白。
堆栈跟踪:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Convert.ToDecimal(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDecimal(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Oracle.DataAccess.Client.OracleDataReader.ChangeType(Object sourceValue, Type targetType)
at Oracle.DataAccess.Client.OracleDataReader.GetValue(Int32 i)
at System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
at System.Data.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
奇怪的是我没有进行任何类型转换。
PS:数据库是Oracle 10g,但由于我使用的是EF,我想这并不重要,但以防万一你需要这个细节。