Пример #1
0
 private static void BeforeBag(IModelInspector modelinspector, PropertyPath member,
                               IBagPropertiesMapper propertycustomizer)
 {
     propertycustomizer.Key(x => x.Column(member.GetContainerEntity(modelinspector).Name + "Id"));
     propertycustomizer.Cascade(Cascade.All);
     propertycustomizer.Inverse(false);
     propertycustomizer.Lazy(CollectionLazy.NoLazy);
 }
Пример #2
0
 public static void OneToManyConvention(IModelInspector modelInspector, PropertyPath member, IBagPropertiesMapper map)
 {
     var inv = member.LocalMember.GetInverseProperty();
     if (inv == null)
     {
         map.Key(x => x.Column(member.GetContainerEntity(modelInspector).Name + "Id"));
         map.Cascade(Cascade.All | Cascade.DeleteOrphans);
         map.BatchSize(20);
         map.Inverse(true);
     }
 }
Пример #3
0
        private void NameKeyColumn(IModelInspector modelinspector, PropertyPath member, IBagPropertiesMapper propertycustomizer)
        {
            var association = BidirectionAssociation.AnalyzeManyToOne(member);

            var columnName = association.IsBidirectional
                           ? association.ColumnNameOnCollectionSide
                           : member.GetRootMember().ReflectedType.Name + "Id";

            propertycustomizer.Key(keyMapper => keyMapper.Column(columnName));

            propertycustomizer.Inverse(association.IsBidirectional);
        }
Пример #4
0
        public static void OneToManyConvention(IModelInspector modelInspector, PropertyPath member, IBagPropertiesMapper map)
        {
            var inv = member.LocalMember.GetInverseProperty();

            if (inv == null)
            {
                map.Key(x => x.Column(member.GetContainerEntity(modelInspector).Name + "Id"));
                map.Cascade(Cascade.All | Cascade.DeleteOrphans);
                map.BatchSize(20);
                map.Inverse(true);
            }
        }
Пример #5
0
        void ApplyBagConvention(IModelInspector mi, PropertyPath type, IBagPropertiesMapper map)
        {
            map.Cascade(Cascade.All | Cascade.DeleteOrphans);
            map.Key(km => km.Column(type.LocalMember.DeclaringType.Name + "_id"));

            var bagType    = type.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType();
            var parentType = type.LocalMember.DeclaringType;

            if (bagType.HasPublicPropertyOf(parentType))
            {
                map.Inverse(true);
            }
        }
Пример #6
0
 private static void MapBag(IModelInspector modelinspector, PropertyPath member, IBagPropertiesMapper bag)
 {
     bag.Key(key =>
     {
         string keyColumnName = string.Format("{0}Id", member.LocalMember.ReflectedType.Name);
         key.Column(keyColumnName);
         string foreignKey = string.Format("FK_{0}__{1}__{2}",
                                           member.LocalMember.ReflectedType.Name, member.LocalMember.Name, keyColumnName);
         key.ForeignKey(foreignKey);
     });
     bag.Fetch(CollectionFetchMode.Subselect);
     bag.Cascade(Cascade.Persist);
     bag.Inverse(true);
 }
Пример #7
0
        public static void MapBag(IModelInspector modelInspector, PropertyPath member, IBagPropertiesMapper map)
        {
            var inv = member.LocalMember.GetInverseProperty();

            if (inv == null)
            {
                map.Key(x => x.Column(member.GetContainerEntity(modelInspector).Name + "Id"));
                //map.Cascade(Cascade.All | Cascade.DeleteOrphans);
                map.BatchSize(20);
                map.Inverse(true);
                var elementType           = member.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType();
                var genericCollectionType = typeof(DomainListType <>);
                var collectionType        = genericCollectionType.MakeGenericType(new[] { elementType });
                map.Type(collectionType);
            }
        }
Пример #8
0
 /// <summary>
 /// Applies any conventions to bag properties.
 /// </summary>
 /// <param name="mapper">The mapper.</param>
 /// <param name="member"> </param>
 protected virtual void ApplyBagConventions(IBagPropertiesMapper mapper, PropertyPath member)
 {
     mapper.Inverse(true);
 }