• 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;
    }
    
  • 相关阅读:
    【CodeForces 788B】奇妙的一笔画问题
    数论day2——离散对数、元根
    学习阶段总结(1)
    Flask特殊装饰器
    Flask蓝图
    Flask对象配置
    Flask实例化配置
    Flask路由
    Flask Session
    Flask jinja2
  • 原文地址:https://www.cnblogs.com/61007257Steven/p/10255591.html
Copyright © 2020-2023  润新知