public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            if (!_precisionTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
            {
                // Doesn't apply
                return null;
            }

            var storeProperty = model.GetColumn(property);
            var defaultPrecision = (byte)storeProperty.PrimitiveType.FacetDescriptions
                .First(d => d.FacetName == DbProviderManifest.PrecisionFacetName).DefaultValue;

            // NOTE: This facet is not propagated to the conceptual side of the reverse
            //       engineered model.
            var precision = storeProperty.Precision ?? defaultPrecision;

            if (precision == defaultPrecision)
            {
                // By convention
                return null;
            }

            return new PrecisionDateTimeConfiguration { Precision = precision };
        }
        public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            var columnProperty = model.GetColumn(property);

            if (property.IsKey() && _identityKeyTypes.Contains(property.PrimitiveType.PrimitiveTypeKind))
            {
                if (columnProperty.IsStoreGeneratedIdentity)
                {
                    // By convention
                    return null;
                }
            }
            else if (columnProperty.IsTimestamp())
            {
                // By convention
                return null;
            }
            else if (columnProperty.StoreGeneratedPattern == StoreGeneratedPattern.None)
            {
                // Doesn't apply
                return null;
            }

            return new DatabaseGeneratedConfiguration { StoreGeneratedPattern = columnProperty.StoreGeneratedPattern };
        }
        public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            if (!model.GetColumn(property).IsTimestamp())
            {
                // Doesn't apply
                return null;
            }

            return new TimestampConfiguration();
        }
        public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            if (property.Nullable
                || property.PrimitiveType.ClrEquivalentType.IsValueType
                || property.IsKey()
                || model.GetColumn(property).IsTimestamp())
            {
                // By convention
                return null;
            }

            return new RequiredConfiguration();
        }
Exemplo n.º 5
0
        public IConfiguration Discover(EdmProperty property, DbModel model)
        {
            Debug.Assert(property != null, "property is null.");
            Debug.Assert(model != null, "model is null.");

            var columnProperty = model.GetColumn(property);

            string name = null;
            if (_code.Property(property) != columnProperty.Name)
            {
                name = columnProperty.Name;
            }

            var providerManifest = model.GetProviderManifest(_dependencyResolver);

            var defaultTypeName = providerManifest.GetStoreType(property.TypeUsage)
                .EdmType.Name;

            string typeName = null;
            if (!columnProperty.TypeName.EqualsIgnoreCase(defaultTypeName))
            {
                typeName = columnProperty.TypeName;
            }

            var entityType = (EntityType)property.DeclaringType;
            var keyIndex = entityType.KeyMembers.IndexOf(property);

            int? order = null;
            if (keyIndex != -1 && entityType.KeyMembers.Count > 1)
            {
                order = keyIndex;
            }

            if (name == null && typeName == null && order == null)
            {
                // By convention
                return null;
            }

            return new ColumnConfiguration { Name = name, TypeName = typeName, Order = order };
        }