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(string.Concat(propertyPath.GetContainerEntity(modelInspector).
                                                                      Name,
                                                                      ConventionNames.PrimaryKeyPostfix)));
                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);
                }
            }
        }
Beispiel #5
0
 public static void MapSet(IModelInspector modelInspector, PropertyPath member, ISetPropertiesMapper map)
 {
 }
 public void InvokeCustomizers(PropertyPath member, ISetPropertiesMapper mapper)
 {
     InvokeCustomizers(collectionCustomizers, member, mapper);
     InvokeCustomizers(setCustomizers, member, mapper);
 }
 protected virtual void OnBeforeMapSet(IModelInspector modelInspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
 {
 }
 public static void MapSetWithCascadePersist(IModelInspector modelinspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
 {
     propertyCustomizer.Cascade(Cascade.Persist);
 }
Beispiel #9
0
 protected virtual void ApplySetConventions(ISetPropertiesMapper mapper, PropertyPath member)
 {
     mapper.Inverse(true);
 }
Beispiel #10
0
 protected virtual void OnAfterMapSet(IModelInspector modelInspector, PropertyPath member, ISetPropertiesMapper propertyCustomizer)
 {
 }
Beispiel #11
0
 private static void KeyColumnNaming(IModelInspector modelinspector, PropertyPath member, ISetPropertiesMapper propertycustomizer)
 {
     var columnName = BidirectionAssociation.AnalyzeManyToOne(member).ColumnNameOnCollectionSide;
     propertycustomizer.Key(km => km.Column(columnName));
 }