Esempio n. 1
0
        /// <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);
        }
Esempio n. 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>()
        {
            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);
        }