Ejemplo n.º 1
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        protected virtual bool IsCandidatePrimitiveProperty([NotNull] PropertyInfo propertyInfo)
        {
            Check.NotNull(propertyInfo, nameof(propertyInfo));

            return(propertyInfo.IsCandidateProperty() &&
                   _typeMapper.FindMapping(propertyInfo) != null);
        }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual InternalEntityTypeBuilder Apply(InternalEntityTypeBuilder entityTypeBuilder)
        {
            Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder));
            var entityType = entityTypeBuilder.Metadata;

            if (entityType.HasClrType())
            {
                var candidates = entityType.ClrType.GetRuntimeProperties();

                foreach (var propertyInfo in candidates)
                {
                    if (!(propertyInfo.IsCandidateProperty() &&
                          _typeMapper.FindMapping(propertyInfo) != null) &&
                        propertyInfo.IsCandidateProperty(publicOnly: false))
                    {
                        var factory = _parameterBindingFactories.FindFactory(propertyInfo.PropertyType, propertyInfo.Name);

                        if (factory != null)
                        {
                            var serviceProperty = entityType.FindServiceProperty(propertyInfo.Name);
                            if (serviceProperty == null ||
                                serviceProperty.PropertyInfo != propertyInfo)
                            {
                                serviceProperty = entityType.AddServiceProperty(propertyInfo, ConfigurationSource.Convention);
                            }

                            serviceProperty.SetParameterBinding(
                                (ServiceParameterBinding)factory.Bind(entityType, propertyInfo.PropertyType, propertyInfo.Name));
                        }
                    }
                }
            }

            return(entityTypeBuilder);
        }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual Type FindCandidateNavigationPropertyType([NotNull] PropertyInfo propertyInfo)
        {
            Check.NotNull(propertyInfo, nameof(propertyInfo));

            return(propertyInfo.FindCandidateNavigationPropertyType(
                       m => _typeMapper.FindMapping(m) != null));
        }
Ejemplo n.º 4
0
        public static Type FindCandidateNavigationPropertyType(
            this PropertyInfo propertyInfo,
            ICoreTypeMapper typeMapper,
            IParameterBindingFactories parameterBindingFactories)
        {
            var targetType         = propertyInfo.PropertyType;
            var targetSequenceType = targetType.TryGetSequenceType();

            if (!propertyInfo.IsCandidateProperty(targetSequenceType == null))
            {
                return(null);
            }

            targetType = targetSequenceType ?? targetType;
            targetType = targetType.UnwrapNullableType();

            if (typeMapper.FindMapping(propertyInfo) != null ||
                targetType.GetTypeInfo().IsInterface ||
                targetType.GetTypeInfo().IsValueType ||
                targetType == typeof(object) ||
                parameterBindingFactories.FindFactory(propertyInfo.PropertyType, propertyInfo.Name) != null)
            {
                return(null);
            }

            return(targetType);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual bool IsMappedPrimitiveProperty([NotNull] IProperty property)
        {
            Check.NotNull(property, nameof(property));

            return(_typeMapper.FindMapping(property) != null);
        }