コード例 #1
0
        public ListMapper(Type ownerType, Type elementType, HbmList mapping)
        {
            if (ownerType == null)
            {
                throw new ArgumentNullException("ownerType");
            }
            if (elementType == null)
            {
                throw new ArgumentNullException("elementType");
            }
            if (mapping == null)
            {
                throw new ArgumentNullException("mapping");
            }
            OwnerType    = ownerType;
            ElementType  = elementType;
            this.mapping = mapping;
            if (mapping.Key == null)
            {
                mapping.key = new HbmKey();
            }
            keyMapper = new KeyMapper(ownerType, mapping.Key);
            var listIndex = new HbmListIndex();

            mapping.Item         = listIndex;
            listIndexMapper      = new ListIndexMapper(ownerType, listIndex);
            entityPropertyMapper = new AccessorPropertyMapper(ownerType, mapping.Name, x => mapping.access = x);
        }
コード例 #2
0
 public void WhenAssignReferenceToNullThenNullifyReference()
 {
     var hbm = new HbmKey();
     var km = new KeyMapper(typeof(Animal), hbm);
     km.PropertyRef(null);
     hbm.propertyref.Should().Be.Null();
 }
コード例 #3
0
 public void WhenExplicitAssignementThenOverrideDefaultColumnName()
 {
     var hbm = new HbmKey();
     var km = new KeyMapper(typeof(Animal), hbm);
     km.Column("blha");
     hbm.Columns.First().name.Should().Be.EqualTo("blha");
 }
コード例 #4
0
 public void AutoAssignColumnNameByDefault()
 {
     var hbm = new HbmKey();
     var km = new KeyMapper(typeof (Animal), hbm);
     hbm.Columns.Should().Have.Count.EqualTo(1);
     hbm.Columns.First().name.Should().Not.Be.Empty().And.Not.Be.Null();
 }
コード例 #5
0
        public void AssignPropertyReference()
        {
            var hbm = new HbmKey();
            var km = new KeyMapper(typeof(Animal), hbm);

            km.PropertyRef(ForClass<Animal>.Property(x=> x.Name));
            hbm.propertyref.Should().Be("Name");
        }
コード例 #6
0
 public void AssignOnDeleteAction()
 {
     var hbm = new HbmKey();
     var km = new KeyMapper(typeof(Animal), hbm);
     km.OnDelete(OnDeleteAction.Cascade);
     hbm.ondelete.Should().Be.EqualTo(HbmOndelete.Cascade);
     km.OnDelete(OnDeleteAction.NoAction);
     hbm.ondelete.Should().Be.EqualTo(HbmOndelete.Noaction);
 }
コード例 #7
0
 public JoinedSubclassMapper(Type subClass, HbmMapping mapDoc)
     : base(subClass, mapDoc)
 {
     var toAdd = new[] { classMapping };
     classMapping.name = subClass.GetShortClassName(mapDoc);
     classMapping.extends = subClass.BaseType.GetShortClassName(mapDoc);
     if (classMapping.key == null)
     {
         classMapping.key = new HbmKey { column1 = subClass.BaseType.Name.ToLowerInvariant() + "_key" };
     }
     keyMapper = new KeyMapper(subClass, classMapping.key);
     mapDoc.Items = mapDoc.Items == null ? toAdd : mapDoc.Items.Concat(toAdd).ToArray();
 }
コード例 #8
0
        public void AssignUpdate()
        {
            var hbm = new HbmKey();
            var km = new KeyMapper(typeof(Animal), hbm);

            km.Update(false);
            hbm.update.Should().Be.False();
            hbm.updateSpecified.Should().Be.True();

            km.Update(true);
            hbm.update.Should().Be.True();
            hbm.updateSpecified.Should().Be.True();
        }
コード例 #9
0
        public JoinedSubclassMapper(Type subClass, HbmMapping mapDoc) : base(subClass, mapDoc)
        {
            var toAdd = new[] { classMapping };

            classMapping.name    = subClass.GetShortClassName(mapDoc);
            classMapping.extends = subClass.BaseType.GetShortClassName(mapDoc);
            if (classMapping.key == null)
            {
                classMapping.key = new HbmKey {
                    column1 = subClass.BaseType.Name.ToLowerInvariant() + "_key"
                };
            }
            keyMapper    = new KeyMapper(subClass, classMapping.key);
            mapDoc.Items = mapDoc.Items == null ? toAdd : mapDoc.Items.Concat(toAdd).ToArray();
        }
コード例 #10
0
        public MapMapper(Type ownerType, Type keyType, Type valueType, HbmMap mapping, HbmMapping mapDoc)
        {
            if (ownerType == null)
            {
                throw new ArgumentNullException("ownerType");
            }
            if (keyType == null)
            {
                throw new ArgumentNullException("keyType");
            }
            if (valueType == null)
            {
                throw new ArgumentNullException("valueType");
            }
            if (mapping == null)
            {
                throw new ArgumentNullException("mapping");
            }
            OwnerType    = ownerType;
            KeyType      = keyType;
            ValueType    = valueType;
            this.mapping = mapping;
            this.mapDoc  = mapDoc;
            if (mapping.Key == null)
            {
                mapping.key = new HbmKey();
            }
            keyMapper = new KeyMapper(ownerType, mapping.Key);

            if (KeyType.IsValueType || KeyType == typeof(string))
            {
                mapping.Item = new HbmMapKey {
                    type = KeyType.GetNhTypeName()
                };
            }
            else
            {
                mapping.Item = new HbmMapKeyManyToMany {
                    @class = KeyType.GetShortClassName(mapDoc)
                };
            }
            entityPropertyMapper = new AccessorPropertyMapper(ownerType, mapping.Name, x => mapping.access = x);
        }
コード例 #11
0
		public BagMapper(Type ownerType, Type elementType, HbmBag mapping)
		{
			if (ownerType == null)
			{
				throw new ArgumentNullException("ownerType");
			}
			if (elementType == null)
			{
				throw new ArgumentNullException("elementType");
			}
			if (mapping == null)
			{
				throw new ArgumentNullException("mapping");
			}
			OwnerType = ownerType;
			ElementType = elementType;
			this.mapping = mapping;
			if (mapping.Key == null)
			{
				mapping.key = new HbmKey();
			}
			keyMapper = new KeyMapper(ownerType, mapping.Key);
			entityPropertyMapper = new AccessorPropertyMapper(ownerType, mapping.Name, x => mapping.access = x);
		}
コード例 #12
0
 public void WhenAssignReferenceOutSideTheOwnerEntityThenThrow()
 {
     var hbm = new HbmKey();
     var km = new KeyMapper(typeof(Animal), hbm);
     ActionAssert.Throws<ArgumentOutOfRangeException>(() => km.PropertyRef(ForClass<B>.Property(x => x.Name)));
 }