访问数据实体:InvalidoperationException,"The given model does not contain the type 'Microsoft.Dynamics.Ax.Xpp.EdtArray`1[System.Decimal]"

Accessing a DataEntity : InvalidoperationException, "The given model does not contain the type 'Microsoft.Dynamics.Ax.Xpp.EdtArray`1[System.Decimal]"

我正在努力处理从视图创建的 DataEntity。该场景是 PowerBI 将通过 d365 实例中的“/data”url 使用该实体。当请求实体并且应该生成 json 时,什么也不会发生。当我从浏览器打开 WebDeveloperTools 并为该实体请求 url 时,出现以下错误:

    {
  "error":{
    "code":"","message":"An error has occurred.","innererror":{
      "message":"The given model does not contain the type 'Microsoft.Dynamics.Ax.Xpp.EdtArray`1[System.Decimal]'.",
      "type":"System.InvalidOperationException",
      "stacktrace":"   at System.Web.OData.Formatter.Serialization.ODataSerializerContext.GetEdmType(Object instance, Type type)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateStructuralProperty(IEdmStructuralProperty structuralProperty, EntityInstanceContext entityInstanceContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateStructuralPropertyBag(IEnumerable`1 structuralProperties, EntityInstanceContext entityInstanceContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateEntry(SelectExpandNode selectExpandNode, EntityInstanceContext entityInstanceContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object graph, ODataWriter writer, ODataSerializerContext writeContext)\r\n   
                       at System.Web.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, ODataWriter writer, ODataSerializerContext writeContext)\r\n   
                       at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)\r\n   
                       at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n
                       --- End of stack trace from previous location where exception was thrown ---\r\n   
                       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
                       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__24.MoveNext()\r\n
                       --- End of stack trace from previous location where exception was thrown ---\r\n   
                       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
                       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Owin.HttpMessageHandlerAdapter.<BufferResponseContentAsync>d__13.MoveNext()"
    }
  }
}

这是什么意思,更重要的是我怎样才能避免这种情况?

数据源是一个名为 'TSTimesheetSummaryLine' 的视图。我复制了另一个实体,从中删除了所有内容,将视图作为数据源删除,然后将所有字段从数据源拖放到实体的字段

我注意到该视图确实包含一个实数组(小时)

显然,实数数组可以在视图中使用,但不能在实体中使用。 导致此异常的字段是 "hours",它存储 7 个实际值(一个对应一周中的每一天)。

解决方案:

我将 dataEntity 上 "hours" 的访问修饰符设置为 "Internal",为每个值添加字段("Hours1" 到 "Hours7")并设置值dataEntity

的 "OnPostingLoad"-EventHandler 中的数组中的这些字段