예제 #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 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);
                }
            }
        }
 public static void MapSetWithCascadePersist(IModelInspector modelinspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
 {
     propertyCustomizer.Cascade(Cascade.Persist);
 }