private void SetPropertyAuditMappedBy(PropertyInfo property, PropertyAuditingData propertyData)
        {
            AuditMappedByAttribute auditMappedBy = (AuditMappedByAttribute)Attribute.GetCustomAttribute(property, typeof(AuditMappedByAttribute));

            if (auditMappedBy != null)
            {
                propertyData.AuditMappedBy = auditMappedBy.MappedBy;
                if (!"".Equals(auditMappedBy.PositionMappedBy))
                {
                    propertyData.PositionMappedBy = auditMappedBy.PositionMappedBy;
                }
            }
        }
예제 #2
0
 private static void mightAddIndexToAttribute(AuditMappedByAttribute auditMappedByAttribute, Mapping.Collection collectionValue, IEnumerable <Property> referencedProperties)
 {
     //check index value
     if (!(collectionValue is IndexedCollection indexValue))
     {
         return;
     }
     foreach (var referencedProperty in referencedProperties)
     {
         if (MappingTools.SameColumns(referencedProperty.ColumnIterator, indexValue.Index.ColumnIterator) &&
             !referencedProperty.IsUpdateable &&
             !referencedProperty.IsInsertable)
         {
             auditMappedByAttribute.PositionMappedBy = referencedProperty.Name;
         }
     }
 }
        private static AuditMappedByAttribute createAuditMappedByAttributeIfReferenceImmutable(Mapping.Collection collectionValue, Property referencedProperty)
        {
            AuditMappedByAttribute attr = null;

            //check if bidrectional
            //TODO: backref check here is wrong! But if it's fixed it will be a big breaking change I guess.. For now, an extra table will be created.
            if (!referencedProperty.BackRef && isRelation(collectionValue, referencedProperty))
            {
                attr = new AuditMappedByAttribute {
                    MappedBy = referencedProperty.Name
                };
                if (!referencedProperty.IsUpdateable &&
                    !referencedProperty.IsInsertable &&
                    //check that non update/insert properties are not also part of id!
                    !MappingTools.AnyColumnMatches(referencedProperty.ColumnIterator, referencedProperty.PersistentClass.Identifier.ColumnIterator))
                {
                    attr.ForceInsertOverride = true;
                }
            }
            return(attr);
        }
 private static void addToEntityMeta(AuditMappedByAttribute attribute, EntityMeta entityMeta, MemberInfo memberInfo)
 {
     log.DebugFormat("Adding AuditMappedByAttribute [MappedBy={0}, PositionMappedBy={1}] to member {2}",
                     attribute.MappedBy, attribute.PositionMappedBy, memberInfo);
     entityMeta.AddMemberMeta(memberInfo, attribute);
 }