List tables in AX per X++

From: http://www.eggheadcafe.com/software/aspnet/33876643/x-code-to-return-list-o.aspx

 

(1) Use Dictionary

 

static void findTables(Args _args) { Dictionary dictionary; TableId tableId; tableName tableName; ; dictionary = new Dictionary(); tableId = dictionary.tableNext(0); tableName = dictionary.tableName(tableId); while (tableId) { info(strfmt("%1 - %2",int2str(tableId), tableName)); tableId = dictionary.tableNext(tableId); tableName = dictionary.tableName(tableId); } }

 

(2) Use SqlDictionary

 

The fastest way (for tables existing in SQL backend db):

SQLDictionary dictTable; ; while select * from dictTable where dictTable.fieldId == 0 { print dicttable.name, ' ', dicttable.tabId; } pause;   

 

(3) Use table UtilIdElements

    In  table UtilIdElements, you can find table type objects and so will have all
table names in Ax.

 

UtilIdElements utilIdElements; ; while select utilIdElements where utilIdElements.recordType == utilElementType::Table { info (strfmt("%1 : %2", utilIdElements.id, utilIdElements.name)); }

 

-------------------------------------------------------- 

注 By: 西北小生

所有AOT上的对象都以文件方式存储在本机(AOS)的*.aod文件中。

系统提供了两个接口来访问这个文件:UtilElements和UtilIdElements。实际使用时根据需要自由选择。

如果要修改AOT对象(如修改、删除、添加、编译、重新加载)那么请使用TreeNode。 TreeNode主要是由内核使用的,所以并不是所有的方法都可以在X++中调用和执行。

系统类xUtilElements提供了将UtilElements转换为TreeNode的方法。

在使用TreeNode进行修改时,尽量减少对对象占用的时间跨度,因为系统内核也要使用TreeNode所指的对象。一种变通的方法就是复制一份出来,SysTreeNode为我们提供了这样的方法。

你可能感兴趣的:(sql,list,table,存储,Dictionary)