Example #1
0
 private void OnBeforeMapSet(IModelInspector mi, PropertyPath member, ISetPropertiesMapper map)
 {
     map.Cascade(Cascade.All | Cascade.DeleteOrphans);
     map.BatchSize(50);
     map.Lazy(CollectionLazy.Lazy);
     map.Inverse(true);
 }
        private static void OneToManyConvention(IModelInspector modelInspector, PropertyPath propertyPath, ISetPropertiesMapper setPropertiesMapper)
        {
            var propertyInfo = propertyPath.LocalMember.GetInverseProperty();

            if (propertyInfo == null)
            {
                setPropertiesMapper.Key(km => km.Column(IdentityBuilder.BuildPrimaryKey(propertyPath.GetContainerEntity(modelInspector).Name)));
                setPropertiesMapper.Cascade(Cascade.All | Cascade.DeleteOrphans);
                setPropertiesMapper.BatchSize(20);
                setPropertiesMapper.Inverse(true);
            }
        }
		protected virtual new void BeforeMapSet(IModelInspector modelInspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
		{
			if (modelInspector.IsManyToMany(member.LocalMember) == true)
			{
				propertyCustomizer.Key(x => x.Column(member.LocalMember.DeclaringType.Name + "_Id"));

				Type sourceType = member.LocalMember.DeclaringType;
				Type destinationType = member.LocalMember.GetPropertyOrFieldType().GetGenericArguments().First();
				String [] names = new Type[] { sourceType, destinationType }.Select(x => x.Name).OrderBy(x => x).ToArray();

				//set inverse on the relation of the alphabetically first entity name
				propertyCustomizer.Inverse(sourceType.Name == names.First());
				//set mapping table name from the entity names in alphabetical order
				propertyCustomizer.Table(String.Join("_", names));
			}
		}
        protected void BeforeMapSet(IModelInspector modelInspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
        {
            propertyCustomizer.Cascade(Cascade.All | Cascade.DeleteOrphans);
            propertyCustomizer.Lazy(CollectionLazy.Lazy);
            propertyCustomizer.Fetch(CollectionFetchMode.Select);
            propertyCustomizer.BatchSize(10);

            Type collectionType = member.LocalMember.GetPropertyOrFieldType();

            if (collectionType.IsGenericCollection())
            {
                Type entityType = collectionType.GetGenericArguments()[0];

                if ((entityType == typeof(String)) || (entityType.IsPrimitive == true) || (entityType.IsEnum == true) || (entityType == typeof(DateTime)))
                {
                    //collection of elements
                }
                else
                {
                    propertyCustomizer.Inverse(true);
                }
            }
        }
Example #5
0
 protected virtual void ApplySetConventions(ISetPropertiesMapper mapper, PropertyPath member)
 {
     mapper.Inverse(true);
 }