从实例化的"System.Int16"类型到可空的"System.Decimal"类型的指定转换无效. [英] The specified cast from a materialized 'System.Int16' type to a nullable 'System.Decimal' type is not valid.
本文介绍了从实例化的"System.Int16"类型到可空的"System.Decimal"类型的指定转换无效.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到此错误
从实例化的"System.Int16"类型到可空的"System.Decimal"类型的指定转换无效.
这是代码
i am getting this error
The specified cast from a materialized ''System.Int16'' type to a nullable ''System.Decimal'' type is not valid.
here is code
dataSource.Database.Connection.Open();
// Run the sproc
var reader = cmd.ExecuteReader();
// Read first result set
verbatim_Fields = ((IObjectContextAdapter)dataSource)
.ObjectContext
.Translate<Verbatim_Info_ValuesBO>(reader, "Verbatim_Info_Fields", MergeOption.AppendOnly).ToList();
// Move to second result set and read Posts
reader.NextResult();
verbatim_SurveyData = ((IObjectContextAdapter)dataSource)
.ObjectContext
.Translate<AGLR__Survey_DataBO>(reader, "AGLR__Survey_Data", MergeOption.AppendOnly).ToList();
推荐答案
Well..i"并不是EF专家,但似乎数据库中的某些字段是int,而在您的实体模型中的某些字段是可为null的Decimal.我会更改您模型的类型并将其设置为整数.
Well..i''m not a big EF expert,but it seems some field in the database is an int and in your entity model is a nullable Decimal. I would change type in your model and make it an int.
这篇关于从实例化的"System.Int16"类型到可空的"System.Decimal"类型的指定转换无效.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文