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;
    }
    
  • 相关阅读:
    mycat实例(1)
    Java连接Oracle数据库的示例代码
    文本处理grep命令
    回调函数
    算法基础--快排序,堆排序,归并排序
    c++ 中double与string之间的转换,char *
    c++ 类型转换
    allocator class
    csapp读书笔记-并发编程
    树的遍历-递归方法,非递归方法
  • 原文地址:https://www.cnblogs.com/61007257Steven/p/10255591.html
Copyright © 2011-2022 走看看