Ejemplo n.º 1
0
        public void Can_get_and_set_can_override_annotation()
        {
            var tableColumn = new EdmProperty("C");

            tableColumn.SetAllowOverride(true);

            Assert.True(tableColumn.GetAllowOverride());

            tableColumn.SetAllowOverride(false);

            Assert.False(tableColumn.GetAllowOverride());
        }
Ejemplo n.º 2
0
        internal virtual void Configure(
            EdmProperty column, EntityType table, DbProviderManifest providerManifest,
            bool allowOverride = false,
            bool fillFromExistingConfiguration = false)
        {
            DebugCheck.NotNull(column);
            DebugCheck.NotNull(table);
            DebugCheck.NotNull(providerManifest);

            var existingConfiguration = column.GetConfiguration() as PrimitivePropertyConfiguration;

            if (existingConfiguration != null)
            {
                var overridable = column.GetAllowOverride();

                string errorMessage;
                if ((existingConfiguration.OverridableConfigurationParts
                     & OverridableConfigurationParts.OverridableInSSpace)
                    != OverridableConfigurationParts.OverridableInSSpace &&
                    !overridable &&
                    !allowOverride &&
                    !fillFromExistingConfiguration &&
                    !existingConfiguration.IsCompatible(this, inCSpace: false, errorMessage: out errorMessage))
                {
                    throw Error.ConflictingColumnConfiguration(column.Name, table.Name, errorMessage);
                }

                FillFrom(existingConfiguration, inCSpace: false);
            }

            ConfigureColumnName(column, table);

            if (!string.IsNullOrWhiteSpace(ColumnType))
            {
                column.PrimitiveType = providerManifest.GetStoreTypeFromName(ColumnType);
            }

            if (ColumnOrder != null)
            {
                column.SetOrder(ColumnOrder.Value);
            }

            var storeType
                = providerManifest.GetStoreTypes()
                  .SingleOrDefault(t => t.Name.Equals(column.TypeName, StringComparison.OrdinalIgnoreCase));

            if (storeType != null)
            {
                storeType.FacetDescriptions.Each(f => Configure(column, f));
            }

            column.SetConfiguration(this);
            column.SetAllowOverride(allowOverride);
        }