public NaturalIdMapper(System.Type rootClass, HbmClass classMapping, HbmMapping mapDoc) : base(rootClass, mapDoc)
		{
			if (classMapping == null)
			{
				throw new ArgumentNullException("classMapping");
			}
			this.classMapping = classMapping;
			naturalIdmapping = new HbmNaturalId();
		}
        public void CanSetMutable()
        {
            var mapdoc = new HbmMapping();
            var hbmNaturalId = new HbmNaturalId();
            var nid = new NaturalIdMapper(typeof(EntitySimpleWithNaturalId), hbmNaturalId, mapdoc);

            nid.Mutable(true);
            hbmNaturalId.mutable.Should().Be.True();
        }
Esempio n. 3
0
		private void BindNaturalId(HbmNaturalId naturalid, PersistentClass rootClass, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			if (naturalid == null)
			{
				return;
			}
			//by default, natural-ids are "immutable" (constant)
			var propBinder = new PropertiesBinder(mappings, rootClass, dialect);
			var uk = new UniqueKey { Name = "_UniqueKey", Table = rootClass.Table };
			propBinder.Bind(naturalid.Properties, inheritedMetas, property =>
				{
					if (!naturalid.mutable)
						property.IsUpdateable = false;
					property.IsNaturalIdentifier = true;

					uk.AddColumns(property.ColumnIterator.OfType<Column>());
				});

			rootClass.Table.AddUniqueKey(uk);	
		}
 public void NaturalId(Action<INaturalIdMapper> naturalIdMapping)
 {
     if(naturalIdMapper == null)
     {
         var hbmNaturalId = new HbmNaturalId();
         classMapping.naturalid = hbmNaturalId;
         naturalIdMapper = new NaturalIdMapper(Container, hbmNaturalId, MapDoc);
     }
     naturalIdMapping(naturalIdMapper);
 }
 public NaturalIdMapper(Type rootClass, HbmNaturalId naturalIdmapping, HbmMapping mapDoc)
     : base(rootClass, mapDoc)
 {
     this.naturalIdmapping = naturalIdmapping;
 }