3

我创建了自己的复杂类型来填充存储过程函数导入的结果。SP 的数据类型是 Int,复杂类型属性也是 Int。当我运行应用程序时,我收到一个错误 '' 上的 '' 属性无法设置为 'String' 值。您必须将此属性设置为“Int32”类型的非空值

/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public Nullable<global::System.Int32> ConfidenceLevel
{
    get
    {
        return _ConfidenceLevel;
    }
    set
    {
        OnConfidenceLevelChanging(value);
        ReportPropertyChanging("ConfidenceLevel");
        _ConfidenceLevel = StructuralObject.SetValidValue(value);
        ReportPropertyChanged("ConfidenceLevel");
        OnConfidenceLevelChanged();
    }
}
private Nullable<global::System.Int32> _ConfidenceLevel;
partial void OnConfidenceLevelChanging(Nullable<global::System.Int32> value);
partial void OnConfidenceLevelChanged();

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

堆栈跟踪:在 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.Coordinator1.ReadNextElement(Shaper shaper) 在 System.Data.Common.Internal.Materialization.Shaper 1.SimpleEnumerator.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 在 System.Collections.Generic.List 1..ctor(IEnumerable1集合)在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) 在 ...DataAccess.cs 中的 ..Models.Repository.DataAccess.GetExtractAllLimits():在 ...GetExtractAllLimits() 中的第 19 行。 ...Service.svc.cs:第 17 行 SyncInvokeGetExtractAllLimits(Object , Object[] , Object[] ) 在 System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) 在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

我尝试将属性设置为可为空,并删除并重新添加了该属性,但仍然没有任何效果。

我注意到一些旧帖子有几乎相同的问题但没有答案,这是 EF 的错误吗?

4

0 回答 0