crm2011查询表的关联关系
来源:互联网 发布:京瓷打印机扫描软件 编辑:程序博客网 时间:2024/06/09 18:53
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
/// <summary>
/// 查询CRM关联关系
/// </summary>
public class RelationshipHelper
{
public void Retrieve(IOrganizationService service)
{
//构造Request对象
RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest();
request.EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.Relationships;
//是否已经发布
request.RetrieveAsIfPublished = true;
RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)service.Execute(request);
if (response != null && response.EntityMetadata.Length > 0)
{
foreach (EntityMetadata currentEntity in response.EntityMetadata)
{
//对应实体的名称
System.Console.WriteLine("Entity,LogicalName: " + currentEntity.LogicalName);
//遍历一对多关系
foreach (OneToManyRelationshipMetadata currentRelationship in currentEntity.OneToManyRelationships)
{
//关系的架构名称
System.Console.WriteLine("SchemaName: " + currentRelationship.SchemaName);
//引用的实体
System.Console.WriteLine("ReferencingEntity: " + currentRelationship.ReferencingEntity);
//引用实体的属性
System.Console.WriteLine("ReferencingAttribute: " + currentRelationship.ReferencingAttribute);
//被引用的实体
System.Console.WriteLine("ReferencedEntity: " + currentRelationship.ReferencedEntity);
//被引用实体的属性
System.Console.WriteLine("ReferencedAttribute: " + currentRelationship.ReferencedAttribute);
}
//遍历多对多关系
foreach (ManyToManyRelationshipMetadata currentRelationship in currentEntity.ManyToManyRelationships)
{
//关系的架构名称
System.Console.WriteLine("SchemaName: " + currentRelationship.SchemaName);
//实体1名称
System.Console.WriteLine("Entity1LogicalName: " + currentRelationship.Entity1LogicalName);
//实体1的属性
System.Console.WriteLine("Entity1IntersectAttribute: " + currentRelationship.Entity1IntersectAttribute);
//实体2名称
System.Console.WriteLine("Entity2LogicalName: " + currentRelationship.Entity2LogicalName);
//实体2的属性
System.Console.WriteLine("Entity2IntersectAttribute: " + currentRelationship.Entity2IntersectAttribute);
}
//遍历多对一关系
foreach (OneToManyRelationshipMetadata currentRelationship in currentEntity.ManyToOneRelationships)
{
//关系的架构名称
System.Console.WriteLine("SchemaName: " + currentRelationship.SchemaName);
//引用的实体
System.Console.WriteLine("ReferencingEntity: " + currentRelationship.ReferencingEntity);
//引用实体的属性
System.Console.WriteLine("ReferencingAttribute: " + currentRelationship.ReferencingAttribute);
//被引用的实体
System.Console.WriteLine("ReferencedEntity: " + currentRelationship.ReferencedEntity);
//被引用实体的属性
System.Console.WriteLine("ReferencedAttribute: " + currentRelationship.ReferencedAttribute);
}
}
}
}
}
- crm2011查询表的关联关系
- 一对多关系的多表关联查询
- 多对多关系的多表关联查询
- MyBatis--关联关系查询
- MyBatis--关联关系查询--一对多--多表连接查询
- 关联关系表的设计
- crm2011查询审核记录
- MyBatis--关联关系查询--自关联
- MyBatis--关联关系查询--自关联--一对多--查询指定父节点的所有子节点
- hibernate关联映射关系带来的弊病---> 无意义的查询
- hibernate3 动态查询,关联关系
- HQL实现多对多关联查询(无关系表的映射)
- 学生表、课程表多对多关联关系的常见查询
- hibernat没有关联关系的添加记录和查询记录
- Mysql联合查询UNION和UNION ALL的使用介绍 可以查询出多张没有关联关系的表的数据
- hibernate的关联表查询
- 查询关联主键的表
- 两个表的关联查询
- 汉明码与交织技术
- 控制器模块和操作
- cas client入门之二:web.xml 配置
- Top popular android test automation tools introduction
- 集合Map常用取值方法:
- crm2011查询表的关联关系
- 那年花开,徒惹是非
- 康托展开与其逆运算
- CISCO Configuration Examples and TechNotes
- Arcgis Add-In开发入门实例
- Oracle常见面试题
- 如何规范自己的技术博客
- servlet用反射代替if..else
- Oracle11g学习笔记