/// <summary>
        /// Configures a convention that applies on all properties of the entity.
        /// </summary>
        /// <returns>A configuration object for the convention.</returns>
        protected PropertyConventionConfiguration Properties()
        {
            var config = new PropertyConventionConfiguration();

            ConventionConfigurations.Add(config);

            return(config);
        }
Exemple #2
0
        /// <summary>
        /// Configures a convention that applies on all the properties of a specified type of the entity.
        /// </summary>
        /// <typeparam name="T">The type of the properties that the convention will apply to.</typeparam>
        /// <returns>A configuration object for the convention.</returns>
        protected PropertyConventionConfiguration Properties <T>()
        {
            // Get the underlying type for a nullale type. (int? -> int)
            var underlyingType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);
            var config         = new PropertyConventionConfiguration().Where(p => p.PropertyType == underlyingType);

            ConventionConfigurations.Add(config);

            return(config);
        }
        /// <summary>
        /// Configures a convention that applies on all the properties of a specified type of the entity.
        /// </summary>
        /// <typeparam name="T">The type of the properties that the convention will apply to.</typeparam>
        /// <returns>A configuration object for the convention.</returns>
        protected PropertyConventionConfiguration Properties <T>()
        {
            var type = typeof(T);
            PropertyConventionConfiguration config;

            if (Nullable.GetUnderlyingType(type) != null)
            {
                // Convention defined for nullable type, match nullable properties
                config = new PropertyConventionConfiguration().Where(p => p.PropertyType == type);
            }
            else
            {
                // Convention defined for non-nullable types, match both nullabel and non-nullable properties
                config = new PropertyConventionConfiguration().Where(p => (Nullable.GetUnderlyingType(p.PropertyType) ?? p.PropertyType) == type);
            }
            ConventionConfigurations.Add(config);

            return(config);
        }