Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
如何查询某个实体的Crm2011 全局选项集?2011中如何获取某实体的EntityTypeCode

Svar 如何查询某个实体的Crm2011 全局选项集?2011中如何获取某实体的EntityTypeCode

Alle besvarelser

  • 18. april 2012 03:46
     
     

    SDK上有这样的消息你试试

    RetrieveEntityRequest

    RetrieveAttributeRequest


    windows live Id :hellohongfu@hotmail.com

  • 19. april 2012 13:10
     
     
    SDK上有这样的消息

    活性炭椰壳活性炭:http://www.hyhxtc.com

  • 20. april 2012 17:06
     
     Svar Har kode
    #region 查询实体元数据
            /// <summary>
            /// 查询实体数据
            /// </summary>
            /// <param name="service"></param>
            private List<CRMEntity> GetEntityMetadata(IOrganizationService service, bool isContainsAttribute = false)
            {
                List<CRMEntity> list = new List<CRMEntity>();
                RetrieveAllEntitiesRequest request;
                if (isContainsAttribute)
                {
                    request = new RetrieveAllEntitiesRequest()
                    {
                        EntityFilters = EntityFilters.Attributes,
    
    
                        RetrieveAsIfPublished = true
                    };
                }
                else
                {
                    request = new RetrieveAllEntitiesRequest()
                    {
                        EntityFilters = EntityFilters.Entity,
    
    
                        RetrieveAsIfPublished = true
                    };
                }
    
                // Retrieve the MetaData.
                RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)service.Execute(request);
    
                foreach (var item in response.EntityMetadata)
                {
    
                    if (item.IsCustomizable.Value == true && string.IsNullOrEmpty(item.LogicalName) == false)
                    {
                        CRMEntity entity = new CRMEntity();
                        entity.ObjectTypeCode = item.ObjectTypeCode.ToString();
                        entity.DisPlayname = getDisplayName(item.DisplayName);
                        entity.LogicalName = item.LogicalName;
                        //Response.Write("ObjectTypeCode:" + item.ObjectTypeCode.ToString() + "   entityname:" + item.LogicalName + " displayname:" + getDisplayName(item.DisplayName) + "</br>");
                        GetAttributes(item, ref  entity);
                        list.Add(entity);
                    }
                }
                var data = list.OrderBy(c => c.LogicalName).OrderByDescending(c => c.LogicalName);
                return data.ToList();
            }
            /// <summary>
            /// 填充实体属性
            /// </summary>
            /// <param name="entity"></param>
            /// <param name="myentity"></param>
            public void GetAttributes(EntityMetadata entity, ref CRMEntity myentity)
            {
                List<CRMAttribute> list = new List<CRMAttribute>();
                if (entity.Attributes != null)
                {
                    foreach (var item in entity.Attributes)
                    {
                        if (item.IsCustomizable.Value == true)
                        {
                            CRMAttribute attibute = new CRMAttribute();
                            attibute.AttributeType = item.AttributeType.Value.ToString();
                            attibute.DisPlayname = getDisplayName(item.DisplayName);
                            attibute.LogicalName = item.LogicalName.ToString();
                            list.Add(attibute);
                            // Response.Write("LogicalName:" + item.LogicalName.ToString() + " displayname:" + getDisplayName(item.DisplayName) + "type;" + item.AttributeType.Value + "</br>");
                        }
                    }
                    myentity.Attributes = list.ToArray();
                }
            }
            string getDisplayName(Microsoft.Xrm.Sdk.Label lable2)
            {
                if (lable2.UserLocalizedLabel == null)
                    return string.Empty;
                else
                    return lable2.UserLocalizedLabel.Label;
    
            }
            #endregion


    windows live Id :hellohongfu@hotmail.com

    • Markeret som svar af Jemas Yang 23. oktober 2012 07:26
    •  
  • 23. oktober 2012 07:11
     
     

    说的不错啊

  • 23. oktober 2012 07:13
     
     
    SDK上有这样的消息 www.ysthxt8.com