zoukankan      html  css  js  c++  java
  • Aras学习笔记 (35) 根据Source Id提取关联Related Item列表的通用方法

    在操作Aras Item时经常需要根据Source Item Id来提取Related Item列表,实际上两个ItemType之间的关系是通过Relationship来实现,关系结构如下图。

    通用方法为:

    /// <summary>
    /// 根据Source Id获取Related Item List
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="SourceItemTypeName"></param>
    /// <param name="RelationshipItemTypeName"></param>
    /// <param name="RelatedItemTypeName"></param>
    /// <param name="SourceId"></param>
    /// <returns></returns>
    public List<T> GetListBySourceId<T>(string SourceItemTypeName, string RelationshipItemTypeName, string RelatedItemTypeName, string SourceId)
    {
    	List<T> list = new List<T>();
    
    	string aml = @"<AML>
                                    <Item type='{0}' action='get'>
                                        <related_id>
                                            <Item type='{1}' action='get'>
                                            </Item>
                                        </related_id>
                                        <source_id>
                                            <Item type='{2}' action='get'>
                                                <id>{3}</id>
                                            </Item>
                                        </source_id>
                                    </Item>
                               </AML>";
    
    	if (innovator != null)
    	{
    		Item item = innovator.applyAML(string.Format(aml, RelationshipItemTypeName, RelatedItemTypeName, SourceItemTypeName, SourceId));
                    if (item != null)
                    {
                        if (item.node != null || item.nodeList != null)
                        {
                            ModelHelper helper = new ModelHelper();
                            list = helper.GetModelListFromXml<T>(item.dom.InnerXml, "related_id");
                        }
                    }
    	}
    
         return list;
    }
    
  • 相关阅读:
    七种程序设计模式
    理清JavaScript正则表达式
    采用管道处理HTTP请求
    AngularJS之Service4
    Net Core-Razor
    中间件(Middleware)
    Redis集群明细文档(转)
    nginx 301跳转到带www域名方法rewrite(转)
    Redis启动多端口,运行多实例(转)
    web框架之Spring-MVC环境搭建(转)
  • 原文地址:https://www.cnblogs.com/61007257Steven/p/10255591.html
Copyright © 2011-2022 走看看