Esempio n. 1
0
        /// <summary>
        ///     Gets a navigation property on the given entity type. Returns null if no navigation property is found.
        /// </summary>
        /// <param name="entityType"> The entity type to find the navigation property on. </param>
        /// <param name="propertyInfo"> The navigation property on the entity class. </param>
        /// <returns> The navigation property, or null if none is found. </returns>
        public static IMutableNavigation FindNavigation(
            [NotNull] this IMutableEntityType entityType, [NotNull] PropertyInfo propertyInfo)
        {
            Check.NotNull(entityType, nameof(entityType));
            Check.NotNull(propertyInfo, nameof(propertyInfo));

            return(entityType.FindNavigation(propertyInfo.Name));
        }
    private static void AddSmartEnumAndKeyedValueObjects(
        bool validateOnWrite,
        Dictionary <Type, ValueConverter> converterLookup,
        Action <IMutableProperty> configure,
        IMutableEntityType entity)
    {
        foreach (var propertyInfo in entity.ClrType.GetRuntimeProperties())
        {
            // will be handled by "AddConvertersForNavigations"
            if (entity.FindNavigation(propertyInfo) is not null)
            {
                continue;
            }

            // wil be handled by AddConverterForScalarProperties
            if (entity.FindProperty(propertyInfo) is not null)
            {
                continue;
            }

            if (!propertyInfo.IsCandidateProperty())
            {
                continue;
            }

            var propertyType = propertyInfo.PropertyType;
            var metadata     = ValueObjectMetadataLookup.Find(propertyType);

            if (metadata is null)
            {
                continue;
            }

            var property = entity.AddProperty(propertyInfo);

            SetConverterAndExecuteCallback(validateOnWrite, converterLookup, configure, property);
        }
    }