代码之家  ›  专栏  ›  技术社区  ›  D.J.

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

  •  0
  • D.J.  · 技术社区  · 7 年前

    我正在使用一个从视图创建的数据实体。场景是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()"
        }
      }
    }
    

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

    0 回复  |  直到 7 年前
        1
  •  1
  •   D.J.    7 年前

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

    解决方案