Example #1
0
        public void ApplyMapping(Attribute attribute, System.Reflection.MemberInfo idProperty, Type entityType, NHibernate.Mapping.ByCode.IClassAttributesMapper mapper, MappingContext context)
        {
            var idType = idProperty.GetPropertyOrFieldType();

            if (idType == typeof(Int32) || idType == typeof(Int64))
            {
                new HiloIdAttributeMapper().ApplyMapping(new HiloIdAttribute(), idProperty, entityType, mapper, context);
            }
            else if (idType == typeof(Guid))
            {
                new GuidAttributeMapper().ApplyMapping(new GuidAttribute(), idProperty, entityType, mapper, context);
            }
        }
Example #2
0
        public void ApplyMapping(Attribute attribute, Type type, NHibernate.Mapping.ByCode.IClassAttributesMapper mapper, MappingContext context)
        {
            var cacheAttr = (CacheAttribute)attribute;

            mapper.Cache(m =>
            {
                m.Usage(GetNHibernateCacheUsage(cacheAttr));
                m.Include(GetNHibernateCacheInclude(cacheAttr));

                if (!String.IsNullOrEmpty(cacheAttr.Region))
                {
                    m.Region(cacheAttr.Region);
                }
            });
        }
Example #3
0
 public void ApplyMapping(Attribute attribute, System.Reflection.MemberInfo idProperty, Type entityType, NHibernate.Mapping.ByCode.IClassAttributesMapper mapper, MappingContext context)
 {
     mapper.Id(idProperty, m => m.Generator(Generators.Guid));
 }
Example #4
0
        private void ApplyPropertyAttributeMappings(IModelInspector modelInspector, PropertyPath member, IPropertyMapper propertyCustomizer)
        {
            var context = new MappingContext(modelInspector, Conventions);

            foreach (Attribute attr in member.LocalMember.GetCustomAttributes(false))
            {
                foreach (var mapper in _attributeMapperFactory.GetPropertyAttributeMappers(attr))
                {
                    mapper.ApplyMapping(attr, member, propertyCustomizer, context);
                }
            }
        }
Example #5
0
        private void ApplyIdMappings(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            var member = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(m => modelInspector.IsPersistentId(m));

            if (member != null)
            {
                var idAttr = member.GetCustomAttributes(typeof(IdAttribute), false).OfType<IdAttribute>().FirstOrDefault();

                // If IdAttribute is not specified for persistent id property, then use the default id mapping strategy
                if (idAttr == null)
                {
                    idAttr = new IdAttribute();
                }

                var context = new MappingContext(modelInspector, Conventions);

                foreach (var mapper in _attributeMapperFactory.GetIdAttributeMappers(idAttr))
                {
                    mapper.ApplyMapping(idAttr, member, type, classCustomizer, context);
                }
            }
        }
Example #6
0
        private void ApplyClassLevelAttributeMappings(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            var context = new MappingContext(modelInspector, Conventions);

            foreach (Attribute attr in type.GetCustomAttributes(false))
            {
                foreach(var mapper in _attributeMapperFactory.GetClassAttributeMappers(attr))
                {
                    mapper.ApplyMapping(attr, type, classCustomizer, context);
                }
            }
        }
Example #7
0
 public void ApplyMapping(Attribute attribute, System.Reflection.MemberInfo idProperty, Type entityType, IClassAttributesMapper mapper, MappingContext context)
 {
     mapper.Id(idProperty, IdMappings.HighLowId(context.Conventions.GetTableName(entityType)));
 }
 public void ApplyMapping(Attribute attribute, NHibernate.Mapping.ByCode.PropertyPath property, NHibernate.Mapping.ByCode.IPropertyMapper mapper, MappingContext context)
 {
     mapper.Type(NHibernateUtil.StringClob);
 }