예제 #1
0
            public void AddFromSdkAttribute(EntityMetadataRow parent, AttributeMetadata attribute)
            {
                var row = this.NewAttributeMetadataRow();
                row.EntityMetadataTableRow = parent;
                row.EntityMetadataId = parent.MetadataId;
                row.MetadataId = attribute.MetadataId.GetValueOrDefault();
                row.AttributeOf = attribute.AttributeOf;

                if (attribute.AttributeType == null)
                {
                    row.SetAttributeOfNull();
                }
                else
                {
                    row.AttributeType = (int)attribute.AttributeType.Value;
                }

                row.AttributeTypeName = attribute.AttributeTypeName.Value;

                if (attribute.CanBeSecuredForCreate == null)
                {
                    row.SetCanBeSecuredForCreateNull();
                }
                else
                {
                    row.CanBeSecuredForCreate = attribute.CanBeSecuredForCreate.Value;
                }

                if (attribute.CanBeSecuredForRead == null)
                {
                    row.SetCanBeSecuredForReadNull();
                }
                else
                {
                    row.CanBeSecuredForRead = attribute.CanBeSecuredForRead.Value;
                }

                if (attribute.CanBeSecuredForUpdate == null)
                {
                    row.SetCanBeSecuredForUpdateNull();
                }
                else
                {
                    row.CanBeSecuredForUpdate = attribute.CanBeSecuredForUpdate.Value;
                }

                if (attribute.CanModifyAdditionalSettings == null)
                {
                    row.SetCanModifyAdditionalSettingsNull();
                }
                else
                {
                    row.CanModifyAdditionalSettings = attribute.CanModifyAdditionalSettings.Value;
                }

                if (attribute.ColumnNumber == null)
                {
                    row.SetColumnNumberNull();
                }
                else
                {
                    row.ColumnNumber = attribute.ColumnNumber.Value;
                }

                row.DeprecatedVersion = attribute.DeprecatedVersion;

                if (attribute.Description == null)
                {
                    row.SetDescriptionNull();
                }
                else
                {

                    if (attribute.Description.UserLocalizedLabel == null)
                    {
                        row.SetDescriptionNull();
                    }
                    else
                    {
                        row.Description = attribute.Description.UserLocalizedLabel.Label;
                    }
                }

                if (attribute.DisplayName == null)
                {
                    row.SetDisplayNameNull();
                }
                else
                {

                    if (attribute.DisplayName.UserLocalizedLabel == null)
                    {
                        row.SetDisplayNameNull();
                    }
                    else
                    {
                        row.DisplayName = attribute.DisplayName.UserLocalizedLabel.Label;
                    }
                }

                row.EntityLogicalName = attribute.EntityLogicalName;
                row.IntroducedVersion = attribute.IntroducedVersion;

                if (attribute.IsAuditEnabled == null)
                {
                    row.SetIsAuditEnabledNull();
                }
                else
                {
                    row.IsAuditEnabled = attribute.IsAuditEnabled.Value;
                }

                if (attribute.IsCustomAttribute == null)
                {
                    row.SetIsCustomAttributeNull();
                }
                else
                {
                    row.IsCustomAttribute = attribute.IsCustomAttribute.Value;
                }

                if (attribute.IsCustomizable == null)
                {
                    row.SetIsCustomizableNull();
                }
                else
                {
                    row.IsCustomizable = attribute.IsCustomizable.Value;
                }

                if (attribute.IsManaged == null)
                {
                    row.SetIsManagedNull();
                }
                else
                {
                    row.IsManaged = attribute.IsManaged.Value;
                }

                if (attribute.IsPrimaryId == null)
                {
                    row.SetIsPrimaryIdNull();
                }
                else
                {
                    row.IsPrimaryId = attribute.IsPrimaryId.Value;
                }

                if (attribute.IsPrimaryName == null)
                {
                    row.SetIsPrimaryNameNull();
                }
                else
                {
                    row.IsPrimaryName = attribute.IsPrimaryName.Value;
                }

                row.IsPseudo = false; // attribute.IsPseudo;

                if (attribute.IsRenameable == null)
                {
                    row.SetIsRenameableNull();
                }
                else
                {
                    row.IsRenameable = attribute.IsRenameable.Value;
                }

                if (attribute.IsSecured == null)
                {
                    row.SetIsSecuredNull();
                }
                else
                {
                    row.IsSecured = attribute.IsSecured.Value;
                }

                if (attribute.IsValidForAdvancedFind == null)
                {
                    row.SetIsValidForAdvancedFindNull();
                }
                else
                {
                    row.IsValidForAdvancedFind = attribute.IsValidForAdvancedFind.Value;
                }

                if (attribute.IsValidForCreate == null)
                {
                    row.SetIsValidForCreateNull();
                }
                else
                {
                    row.IsValidForCreate = attribute.IsValidForCreate.Value;
                }

                if (attribute.IsValidForRead == null)
                {
                    row.SetIsValidForReadNull();
                }
                else
                {
                    row.IsValidForRead = attribute.IsValidForRead.Value;
                }

                if (attribute.IsValidForUpdate == null)
                {
                    row.SetIsValidForUpdateNull();
                }
                else
                {
                    row.IsValidForUpdate = attribute.IsValidForUpdate.Value;
                }

                if (attribute.LinkedAttributeId == null)
                {
                    row.SetLinkedAttributeIdNull();
                }
                else
                {
                    row.LinkedAttributeId = attribute.LinkedAttributeId.Value;
                }

                if (attribute.LogicalName == null)
                {
                    row.SetLogicalNameNull();
                }
                else
                {
                    row.LogicalName = attribute.LogicalName;
                }

                var attType = row.GetAttributeTypeCode();
                switch (attType)
                {
                    case AttributeTypeCode.Decimal:
                        var decAtt = (DecimalAttributeMetadata)attribute;
                        row.MinValue = decAtt.MinValue;
                        row.MaxValue = decAtt.MinValue;
                        row.Precision = decAtt.Precision.GetValueOrDefault();
                        row.SetPrecisionSourceNull();
                        break;
                    case AttributeTypeCode.Double:
                        var doubleAtt = (DoubleAttributeMetadata)attribute;
                        row.MinValue = doubleAtt.MinValue;
                        row.MaxValue = doubleAtt.MinValue;
                        row.Precision = doubleAtt.Precision.GetValueOrDefault();
                        row.SetPrecisionSourceNull();
                        break;
                    case AttributeTypeCode.Money:
                        var moneyAtt = (MoneyAttributeMetadata)attribute;
                        row.MinValue = moneyAtt.MinValue;
                        row.MaxValue = moneyAtt.MinValue;
                        row.Precision = moneyAtt.Precision.GetValueOrDefault();
                        row.PrecisionSource = moneyAtt.PrecisionSource.GetValueOrDefault();
                        break;
                    default:
                        row.SetPrecisionSourceNull();
                        row.SetPrecisionNull();
                        row.SetMaxValueNull();
                        row.SetMinValueNull();
                        break;
                }

                if (attribute.RequiredLevel == null)
                {
                    row.SetRequiredLevelNull();
                }
                else
                {
                    row.RequiredLevel = (int)attribute.RequiredLevel.Value;
                }

                if (attribute.SchemaName == null)
                {
                    row.SetSchemaNameNull();
                }
                else
                {
                    row.SchemaName = attribute.SchemaName;
                }

                this.AddAttributeMetadataRow(row);
            }
예제 #2
0
            public void AddFromSdkAttribute(EntityMetadataRow parent, AttributeMetadata attribute)
            {
                var row = this.NewAttributeMetadataRow();

                row.EntityMetadataTableRow = parent;
                row.EntityMetadataId       = parent.MetadataId;
                row.MetadataId             = attribute.MetadataId.GetValueOrDefault();
                row.AttributeOf            = attribute.AttributeOf;

                if (attribute.AttributeType == null)
                {
                    row.SetAttributeOfNull();
                }
                else
                {
                    row.AttributeType = (int)attribute.AttributeType.Value;
                }

                row.AttributeTypeName = attribute.AttributeTypeName.Value;

                if (attribute.CanBeSecuredForCreate == null)
                {
                    row.SetCanBeSecuredForCreateNull();
                }
                else
                {
                    row.CanBeSecuredForCreate = attribute.CanBeSecuredForCreate.Value;
                }

                if (attribute.CanBeSecuredForRead == null)
                {
                    row.SetCanBeSecuredForReadNull();
                }
                else
                {
                    row.CanBeSecuredForRead = attribute.CanBeSecuredForRead.Value;
                }

                if (attribute.CanBeSecuredForUpdate == null)
                {
                    row.SetCanBeSecuredForUpdateNull();
                }
                else
                {
                    row.CanBeSecuredForUpdate = attribute.CanBeSecuredForUpdate.Value;
                }

                if (attribute.CanModifyAdditionalSettings == null)
                {
                    row.SetCanModifyAdditionalSettingsNull();
                }
                else
                {
                    row.CanModifyAdditionalSettings = attribute.CanModifyAdditionalSettings.Value;
                }

                if (attribute.ColumnNumber == null)
                {
                    row.SetColumnNumberNull();
                }
                else
                {
                    row.ColumnNumber = attribute.ColumnNumber.Value;
                }

                row.DeprecatedVersion = attribute.DeprecatedVersion;


                if (attribute.Description == null)
                {
                    row.SetDescriptionNull();
                }
                else
                {
                    if (attribute.Description.UserLocalizedLabel == null)
                    {
                        row.SetDescriptionNull();
                    }
                    else
                    {
                        row.Description = attribute.Description.UserLocalizedLabel.Label;
                    }
                }

                if (attribute.DisplayName == null)
                {
                    row.SetDisplayNameNull();
                }
                else
                {
                    if (attribute.DisplayName.UserLocalizedLabel == null)
                    {
                        row.SetDisplayNameNull();
                    }
                    else
                    {
                        row.DisplayName = attribute.DisplayName.UserLocalizedLabel.Label;
                    }
                }

                row.EntityLogicalName = attribute.EntityLogicalName;
                row.IntroducedVersion = attribute.IntroducedVersion;

                if (attribute.IsAuditEnabled == null)
                {
                    row.SetIsAuditEnabledNull();
                }
                else
                {
                    row.IsAuditEnabled = attribute.IsAuditEnabled.Value;
                }

                if (attribute.IsCustomAttribute == null)
                {
                    row.SetIsCustomAttributeNull();
                }
                else
                {
                    row.IsCustomAttribute = attribute.IsCustomAttribute.Value;
                }

                if (attribute.IsCustomizable == null)
                {
                    row.SetIsCustomizableNull();
                }
                else
                {
                    row.IsCustomizable = attribute.IsCustomizable.Value;
                }

                if (attribute.IsManaged == null)
                {
                    row.SetIsManagedNull();
                }
                else
                {
                    row.IsManaged = attribute.IsManaged.Value;
                }

                if (attribute.IsPrimaryId == null)
                {
                    row.SetIsPrimaryIdNull();
                }
                else
                {
                    row.IsPrimaryId = attribute.IsPrimaryId.Value;
                }

                if (attribute.IsPrimaryName == null)
                {
                    row.SetIsPrimaryNameNull();
                }
                else
                {
                    row.IsPrimaryName = attribute.IsPrimaryName.Value;
                }

                row.IsPseudo = false; // attribute.IsPseudo;


                if (attribute.IsRenameable == null)
                {
                    row.SetIsRenameableNull();
                }
                else
                {
                    row.IsRenameable = attribute.IsRenameable.Value;
                }

                if (attribute.IsSecured == null)
                {
                    row.SetIsSecuredNull();
                }
                else
                {
                    row.IsSecured = attribute.IsSecured.Value;
                }

                if (attribute.IsValidForAdvancedFind == null)
                {
                    row.SetIsValidForAdvancedFindNull();
                }
                else
                {
                    row.IsValidForAdvancedFind = attribute.IsValidForAdvancedFind.Value;
                }

                if (attribute.IsValidForCreate == null)
                {
                    row.SetIsValidForCreateNull();
                }
                else
                {
                    row.IsValidForCreate = attribute.IsValidForCreate.Value;
                }

                if (attribute.IsValidForRead == null)
                {
                    row.SetIsValidForReadNull();
                }
                else
                {
                    row.IsValidForRead = attribute.IsValidForRead.Value;
                }

                if (attribute.IsValidForUpdate == null)
                {
                    row.SetIsValidForUpdateNull();
                }
                else
                {
                    row.IsValidForUpdate = attribute.IsValidForUpdate.Value;
                }

                if (attribute.LinkedAttributeId == null)
                {
                    row.SetLinkedAttributeIdNull();
                }
                else
                {
                    row.LinkedAttributeId = attribute.LinkedAttributeId.Value;
                }

                if (attribute.LogicalName == null)
                {
                    row.SetLogicalNameNull();
                }
                else
                {
                    row.LogicalName = attribute.LogicalName;
                }

                var attType = row.GetAttributeTypeCode();

                switch (attType)
                {
                case AttributeTypeCode.Decimal:
                    var decAtt = (DecimalAttributeMetadata)attribute;
                    row.MinValue  = decAtt.MinValue;
                    row.MaxValue  = decAtt.MinValue;
                    row.Precision = decAtt.Precision.GetValueOrDefault();
                    row.SetPrecisionSourceNull();
                    break;

                case AttributeTypeCode.Double:
                    var doubleAtt = (DoubleAttributeMetadata)attribute;
                    row.MinValue  = doubleAtt.MinValue;
                    row.MaxValue  = doubleAtt.MinValue;
                    row.Precision = doubleAtt.Precision.GetValueOrDefault();
                    row.SetPrecisionSourceNull();
                    break;

                case AttributeTypeCode.Money:
                    var moneyAtt = (MoneyAttributeMetadata)attribute;
                    row.MinValue        = moneyAtt.MinValue;
                    row.MaxValue        = moneyAtt.MinValue;
                    row.Precision       = moneyAtt.Precision.GetValueOrDefault();
                    row.PrecisionSource = moneyAtt.PrecisionSource.GetValueOrDefault();
                    break;

                default:
                    row.SetPrecisionSourceNull();
                    row.SetPrecisionNull();
                    row.SetMaxValueNull();
                    row.SetMinValueNull();
                    break;
                }

                if (attribute.RequiredLevel == null)
                {
                    row.SetRequiredLevelNull();
                }
                else
                {
                    row.RequiredLevel = (int)attribute.RequiredLevel.Value;
                }

                if (attribute.SchemaName == null)
                {
                    row.SetSchemaNameNull();
                }
                else
                {
                    row.SchemaName = attribute.SchemaName;
                }

                this.AddAttributeMetadataRow(row);
            }