當前位置: 首頁>>代碼示例>>C#>>正文


C# AttributeMetadata.GetType方法代碼示例

本文整理匯總了C#中AttributeMetadata.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# AttributeMetadata.GetType方法的具體用法?C# AttributeMetadata.GetType怎麽用?C# AttributeMetadata.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AttributeMetadata的用法示例。


在下文中一共展示了AttributeMetadata.GetType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CopyData

        private void CopyData(IOrganizationService service, AttributeMetadata from, AttributeMetadata to, Action actions)
        {
            if (!MigrateData) { return; }

            var total = GetRecordCount(service, from);
            var count = 0;

            Trace("Copying data from {0} to {1}", from.LogicalName, to.LogicalName);
            var requests = new OrganizationRequestCollection();
            // Grab from and to, and only update if not equal.  This is to speed things up if it has failed part way through
            foreach (var entity in service.GetAllEntities<Entity>(new QueryExpression(from.EntityLogicalName) { ColumnSet = new ColumnSet(from.LogicalName, to.LogicalName) }))
            {
                if (count++ % 100 == 0 || count == total)
                {
                    if (requests.Any())
                    {
                        PerformUpdates(service, requests);
                    }

                    Trace("Copying {0} / {1}", count, total);
                    requests.Clear();
                }

                var value = entity.GetAttributeValue<Object>(from.LogicalName);
                if (actions.HasFlag(Action.ChangeType) && from.GetType() != to.GetType())
                {
                    value = CopyValue(from, to, value);
                }
                var toValue = entity.GetAttributeValue<Object>(to.LogicalName);
                
                if (value != null)
                {
                    if (value.Equals(toValue)) continue;

                    entity.Attributes[to.LogicalName] = value;
                    requests.Add(new UpdateRequest { Target = entity });
                }
                else if (toValue != null)
                {
                    entity.Attributes[to.LogicalName] = null;
                    requests.Add(new UpdateRequest { Target = entity });
                }
            }

            if (requests.Any())
            {
                PerformUpdates(service, requests);
            }

            Trace("Data Migration Complete", count, total);
        }
開發者ID:ganpathv,項目名稱:DLaB.Xrm.XrmToolBoxTools,代碼行數:51,代碼來源:Logic.cs

示例2: SetEntityLogicalName

 private void SetEntityLogicalName(AttributeMetadata att, string entityLogicalName)
 {
     var prop = att.GetType().GetProperty("EntityLogicalName");
     prop.SetValue(att, entityLogicalName);
 }
開發者ID:ganpathv,項目名稱:DLaB.Xrm.XrmToolBoxTools,代碼行數:5,代碼來源:Logic.cs

示例3: GetAttributeOptionSet

 internal static OptionSetMetadataBase GetAttributeOptionSet(AttributeMetadata attribute)
 {
     OptionSetMetadataBase optionSet = null;
     var type = attribute.GetType();
     if (type == typeof (BooleanAttributeMetadata))
     {
         var metadata = (BooleanAttributeMetadata) attribute;
         return metadata.OptionSet;
     }
     if (type == typeof (StateAttributeMetadata))
     {
         var metadata2 = (StateAttributeMetadata) attribute;
         return metadata2.OptionSet;
     }
     if (type == typeof (PicklistAttributeMetadata))
     {
         var metadata3 = (PicklistAttributeMetadata) attribute;
         return metadata3.OptionSet;
     }
     if (type == typeof (StatusAttributeMetadata))
     {
         var metadata4 = (StatusAttributeMetadata) attribute;
         optionSet = metadata4.OptionSet;
     }
     return optionSet;
 }
開發者ID:snugglesftw,項目名稱:Crm,代碼行數:26,代碼來源:TypeMappingService.cs


注:本文中的AttributeMetadata.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。