예제 #1
0
        void Mapper_AfterMapProperty(
            NHibernate.Mapping.ByCode.IModelInspector modelInspector,
            NHibernate.Mapping.ByCode.PropertyPath propertyPath,
            NHibernate.Mapping.ByCode.IPropertyMapper propertyMapper
            )
        {
            dynamic lm = propertyPath.LocalMember;

            System.Type st = lm.PropertyType; // why NHibernate is hiding PropertyType? thanks to dynamic keyword, nothing can hide from dynamic

            if (st == typeof(Jsonb))
            {
                propertyMapper.Type(typeof(AspNetCoreExample.Infrastructure.NHibernateInfra.JsonbType), parameters: null);
            }
        }
예제 #2
0
        static void Mapper_BeforeMapProperty(
            NHibernate.Mapping.ByCode.IModelInspector modelInspector,
            NHibernate.Mapping.ByCode.PropertyPath propertyPath,
            NHibernate.Mapping.ByCode.IPropertyMapper propertyMapper
            )
        {
            string postgresFriendlyName = propertyPath.ToColumnName().ToLowercaseNamingConvention();

            propertyMapper.Column(postgresFriendlyName);

            System.Type st = propertyPath.LocalMember.GetPropertyOrFieldType();

            // http://www.ienablemuch.com/2018/06/utc-all-things-with-nhibernate-datetime-postgres-timestamptz.html
            if (st == typeof(System.DateTime) || st == typeof(System.DateTime?))
            {
                propertyMapper.Type <Infrastructure.NHibernateInfra.CustomUtcType>();
            }
        }