public void AddCustomDelegatedApplierOnPoid() { var orm = new Mock <IDomainInspector>(); var mapper = new Mapper(orm.Object); var previousPropertyApplierCount = mapper.PatternsAppliers.Poid.Count; mapper.AddPoidPattern(mi => true, (mi, idm) => { }); mapper.PatternsAppliers.Poid.Count.Should().Be(previousPropertyApplierCount + 1); }
public void AddCustomDelegatedApplierOnPoid() { var orm = new Mock<IDomainInspector>(); var mapper = new Mapper(orm.Object); var previousPropertyApplierCount = mapper.PatternsAppliers.Poid.Count; mapper.AddPoidPattern(mi => true, (mi, idm) => { }); mapper.PatternsAppliers.Poid.Count.Should().Be(previousPropertyApplierCount + 1); }
public void ExecuteCustomDelegatedApplierOnPoid() { var orm = new Mock <IDomainInspector>(); orm.Setup(m => m.IsEntity(It.IsAny <Type>())).Returns(true); orm.Setup(m => m.IsRootEntity(It.IsAny <Type>())).Returns(true); orm.Setup(m => m.IsTablePerClass(It.IsAny <Type>())).Returns(true); orm.Setup(m => m.IsPersistentId(It.Is <MemberInfo>(mi => mi.Name == "Id"))).Returns(true); orm.Setup(m => m.IsPersistentProperty(It.Is <MemberInfo>(mi => mi.Name != "Id"))).Returns(true); var mapper = new Mapper(orm.Object); mapper.AddPoidPattern(mi => true, (mi, idm) => idm.Column(mi.ReflectedType.Name + "Id")); var mapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = mapping.RootClasses.Single(); hbmClass.Id.Columns.Single().name.Should().Be("MyClassId"); }
public void HighLowCustomization() { // In this example you can see how configure the HighLowPoidPattern for entities without neither a property nor a field representing the POID var entities = new[] { typeof(Product), typeof(Person), typeof(Address) }; var orm = new ObjectRelationalMapper(); // Instancing the Mapper using the result of Merge var mapper = new Mapper(orm); mapper.AddPoidPattern(mi => mi == null, (x, applyTo) => { applyTo.Generator(new MyHighLowDef { Params = new { max_lo = 100 } }); applyTo.Type((IIdentifierType)NHibernateUtil.Int32); }); orm.TablePerClass(entities); var mapping = mapper.CompileMappingFor(entities); Console.Write(mapping.AsString()); }
public void ExecuteCustomDelegatedApplierOnPoid() { var orm = new Mock<IDomainInspector>(); orm.Setup(m => m.IsEntity(It.IsAny<Type>())).Returns(true); orm.Setup(m => m.IsRootEntity(It.IsAny<Type>())).Returns(true); orm.Setup(m => m.IsTablePerClass(It.IsAny<Type>())).Returns(true); orm.Setup(m => m.IsPersistentId(It.Is<MemberInfo>(mi => mi.Name == "Id"))).Returns(true); orm.Setup(m => m.IsPersistentProperty(It.Is<MemberInfo>(mi => mi.Name != "Id"))).Returns(true); var mapper = new Mapper(orm.Object); mapper.AddPoidPattern(mi => true, (mi, idm) => idm.Column(mi.ReflectedType.Name + "Id")); var mapping = mapper.CompileMappingFor(new[] { typeof(MyClass) }); var hbmClass = mapping.RootClasses.Single(); hbmClass.Id.Columns.Single().name.Should().Be("MyClassId"); }