如何使用 "Incorrect syntax near the keyword 'FROM'" 异常调试复合实体?

How to debug composite entity with "Incorrect syntax near the keyword 'FROM'" exception?

我基于两个新实体创建了一个新的复合实体。这些反过来又基于新的视图,而新的视图又基于新的查询。查询基于标准表和视图以及自定义表的组合。

过去曾创建过类似的复合实体并在工作。

使用数据项目导出复合实体时,出现以下异常:

AX-DIXFRuntime 事件日志中的异常:

System.Exception: Incorrect syntax near the keyword 'FROM'.
   at Microsoft.Dynamics.AX.Framework.Tools.DMF.ServiceProxy.DmfEntitySharedTypesProxy.DoWork[T](Func`1 work)
   at Dynamics.AX.Application.DMFGenerateSSISPackage.`generateFileDataV2(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution, String _defGroupName, DMFFileFormat _fileFormat, DMFDelimiter _rowDelimiter, DMFDelimiter _columnDelimiter, String _codePage, String _locale, NoYes _isFirstRowHeader, NoYes _unicode, String _source, String _textQualifier, DMFXMLStyle _style, String _rootElement, String _filePath, Map _entitySyncVersion, Int32 _previewCount, Boolean @_entitySyncVersion_IsDefaultSet, Boolean @_previewCount_IsDefaultSet) in xppSource://Source/ApplicationFoundation\AxClass_DMFGenerateSSISPackage.xpp:line 1419

AX-DIXFSSISRuntime 事件日志中的异常:

SSISexceptionMessage System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'FROM'. 
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) 
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) 
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) 
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() 
at System.Data.SqlClient.SqlDataReader.get_MetaData() 
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) 
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) 
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) 
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) 
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) 
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) 
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFCompositeEntity.GetDatasetForXMlExport(String stagingString) 
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFCompositeEntity.ExportCompositeEntityToXML() 
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelperService.Service.ServiceHelper.ExportCompositeEntityToXML(DMFCompositeEntity dmfCompEnt) ClientConnectionId:9a234a11-809d-4d88-828d-8981bfb4faa8 Error Number:156,State:1,Class:15 

到目前为止我尝试过的:

问题

我的问题是是否有办法找出导致 Incorrect syntax near the keyword 'FROM' 异常的 SQL 是什么。如果没有办法,我很乐意听到有关如何进一步缩小此问题范围的建议。

问题是由复合实体的标签文本长度和实体名称的长度引起的。它们不得超过 99 个字符的限制。

假设您有两个名称为

的实体
  • VeryLongNameWithSixtyCharactersThatIdentifyTheFirstEntity123(60 个字符)
  • AnotherLongNameWithSeventyCharactersThatIdentifyTheSecondEntity1234567(70 个字符)

同时假设你实体的标签文字如下

  • Label text with 30 characters1

如果导航到工作区 数据管理 并打开实体列表,找到名为 Label text with 31 characters1 的复合实体并打开 "Child entities"。 它将显示 2 个名为

的条目
  • Label text with 30 characters1_VeryLongNameWithSixtyCharactersThatIdentifyTheFirstEntity123(90 个字符)
  • Label text with 30 characters1_AnotherLongNameWithSeventyCharactersThatIdentifyTheSecondEntity1234567(100 个字符)

此复合实体将正确导出。

但是,如果您在第二个实体的名称中添加另一个字符,则子实体的第二个条目将具有 101 个字符。这将导致描述的异常错误。

微软修复

在 Microsoft 文档的 issue 2086 中,他们宣布在编译期间在当前正在调查的 PU 36 中对此进行检查。请参阅 KB4549600。