访问DataEntity:InvalidoperationException,“给定的模型不包含类型'Microsoft.Dynamics.Ax.Xpp.EdtArray`1 [System.Decimal]”

问题描述 投票:0回答:1

我正在使用从视图创建的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”的视图。我复制了另一个实体,从中删除了所有内容,将视图作为数据源删除,然后将所有字段从数据源拖放到实体的字段中

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

axapta x++ dynamics-365-operations
1个回答
1
投票

可以在视图中使用实际数组,但不能在实体中使用。导致此异常的字段是“小时”,它存储7个实际值(每周一天)。

解:

我将dataEntity上的“hours”的access-modifier设置为“Internal”,为每个值添加了字段(“Hours1”到“Hours7”),并在“OnPostingLoad”-EventHandler中为数组设置了theese字段的值。 dataEntity

© www.soinside.com 2019 - 2024. All rights reserved.