惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 小小飞鹰

MMM互助金融/理财源码 js 弹出窗口 防止拦截,突破阻止,保存后打开 .NET开发者必备的工具箱 NBIbatis web/winform框架 NBIbatis 微信框架 NBIbatis 框架体系说明 NBIbatis 基础框架 开源中国上一些有用的开源系统 TfS+强制删除签出锁定项 thinkphp支持大小写url地址访问,不产生下划线 sqlserver 链接 ODBC 访问 MySql ibatis + log4net 配置注意事项 Devexpress GridView内嵌dx:ASPxGridLookup取得控件值乱跳解决方案 【转】Asp.Net MVC及Web API框架配置会碰到的几个问题及解决方案 将关系数据库映射到业务实体 百度贴吧10亿量级LAMP架构分享 [转]ASP.NET中 WebSite 跟 WebProject 的异同 dynamics ax 2009 distinct实现及数组集合 dynamics ax 2009 字段类似的表绑定界面注意
dynamics Ax 2009 实现 union 效果
小小飞鹰 · 2011-08-31 · via 博客园 - 小小飞鹰

Ax中多表关联仅提供Inner Join/Outer Join/Exist join/Not Exist join,而么有union,可以通过Query来实现.

例如 Sql:

select ItemType,GoodsName from table1 where TransDate between g_DateB and g_DateE
union
select ItemType,GoodsName from table2 where TransDate between g_DateB and g_DateE

1 实现[ from table1 ]
    qbd = query.addDataSource(tableNum(table1));
2 实现[ select ItemType,GoodsName ]
    qbd.addSelectionField(fieldnum(table1,ItemType));
    qbd.addSelectionField(fieldnum(table1,GoodsName));
3 实现[ where TransDate between g_DateB and g_DateE ]
  qbd.addRange(fieldnum(table1,TransDate)).value(strfmt("%1..%2", g_DateB,g_DateE));
4 实现[ union ]
    query.queryType(QueryType::Union);
  
代码:
   Query query;
    QueryRun qr;
    QueryBuildDataSource qbd;
    QueryBuildDataSource qbd2;
    Table1 newTable;

    qbd = query.addDataSource(tableNum(table1));
    qbd.addSelectionField(fieldnum(table1,ItemType));
    qbd.addSelectionField(fieldnum(table1,GoodsName));
    qbd.addRange(fieldnum(table1,TransDate)).value(strfmt("%1..%2", g_DateB,g_DateE));

    qbd2 = query.addDataSource(tablenum(table2));
    qbd2.addSelectionField(fieldnum(table2,ItemType));
    qbd2.addSelectionField(fieldnum(table2,GoodsName));
    qbd2.addRange(fieldnum(table2,TransDate)).value(strfmt("%1..%2", g_DateB,g_DateE));


    qbd2.addRange(fieldnum(table2,RecId)).
            value(strfmt("((%1 > %2) || (%3 > %4) || (%5 > %6))",
            fieldstr(table2,Qty),queryValue(0),
            fieldstr(table2,Weight),queryValue(0),
            fieldstr(table2,Volume),queryValue(0)));// OR Condition

    query.queryType(QueryType::Union);
    qr = new QueryRun(query);
    while(qr.next())
    {
     newTable = qr.get(tableNum(table1));
     //do something...
  }