D.J.
D.J.

Reputation: 4034

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

I am struggeling with a DataEntity that is created from a view. The scenario is that the entity will be used by PowerBI via the "/data" url from a d365 instance. When the entity is requested and the json should be generated nothing happens. When i opened the WebDeveloperTools from my browser and i requested the url for this entity i got the following error:

    {
  "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()"
    }
  }
}

What does this mean and more importantly how can i avoid this ?

the datasource is a view called 'TSTimesheetSummaryLine'. i copyied another entity, removed everything from it, dropped the view as datasource and then dragDropped all fields from datasource to the fields of the entity

I noticed that the view does contain a real-array (hours)

Upvotes: 0

Views: 985

Answers (1)

D.J.
D.J.

Reputation: 4034

Appearantly real-arrays can be used in views but not in entities. The field that was causing this exception was "hours", it stores 7 real values (one for each day of week).

Solution:

I set the access-modifier of "hours" on the dataEntity to "Internal", added fields for each value ("Hours1" to "Hours7") and set the values for theese fields from the array in the "OnPostingLoad"-EventHandler of the dataEntity

Upvotes: 1

Related Questions