本文整理汇总了C#中NHibernate.Mapping.ByCode.ExplicitlyDeclaredModel类的典型用法代码示例。如果您正苦于以下问题:C# ExplicitlyDeclaredModel类的具体用法?C# ExplicitlyDeclaredModel怎么用?C# ExplicitlyDeclaredModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExplicitlyDeclaredModel类属于NHibernate.Mapping.ByCode命名空间,在下文中一共展示了ExplicitlyDeclaredModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenSplittedPropertiesThenRegister
public void WhenSplittedPropertiesThenRegister()
{
var inspector = new ExplicitlyDeclaredModel();
var mapper = new ModelMapper(inspector);
mapper.Class<MyClass>(map =>
{
map.Id(x => x.Id, idmap => { });
map.Join("MyClassSplit1", mj=>
{
mj.Property(x => x.SomethingA1);
mj.Property(x => x.SomethingA2);
});
map.Join("MyClassSplit2", mj =>
{
mj.Property(x => x.SomethingB1);
mj.Property(x => x.SomethingB2);
});
map.Property(x => x.Something0);
});
Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<MyClass>.Property(x => x.Something0)), Is.False);
Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<MyClass>.Property(x => x.Something0)), Is.False);
Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<MyClass>.Property(x => x.SomethingA1)), Is.True);
Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<MyClass>.Property(x => x.SomethingA2)), Is.True);
Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<MyClass>.Property(x => x.SomethingB1)), Is.True);
Assert.That(inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<MyClass>.Property(x => x.SomethingB2)), Is.True);
}
示例2: WhenRegisterJoinedSubclassWithNoRootThenCanAskForIsEntity
public void WhenRegisterJoinedSubclassWithNoRootThenCanAskForIsEntity()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsTablePerClassEntity(typeof(Inherited1));
inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
}
示例3: WhenRegisterUnionSubclassWithNoRootThenThrows
public void WhenRegisterUnionSubclassWithNoRootThenThrows()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
Assert.That(() => inspector.IsTablePerConcreteClass(typeof(Inherited1)), Throws.TypeOf<MappingException>());
}
示例4: WhenRegisteredAsComponentThenIsRegistered
public void WhenRegisteredAsComponentThenIsRegistered()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsComponent(typeof(MyComponent));
inspector.IsComponent(typeof(MyComponent)).Should().Be.True();
}
示例5: WhenRegisteredAsComponetThenCantRegisterAsRootEntity
public void WhenRegisteredAsComponetThenCantRegisterAsRootEntity()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsComponent(typeof(MyComponent));
inspector.Executing(x => x.AddAsRootEntity(typeof(MyComponent))).Throws<MappingException>();
}
示例6: WhenMapSplittedPropertiesThenEachPropertyIsInItsSplitGroup
public void WhenMapSplittedPropertiesThenEachPropertyIsInItsSplitGroup()
{
var inspector = new ExplicitlyDeclaredModel();
var mapper = new ModelMapper(inspector);
mapper.Class<MyClass>(map => map.Id(x => x.Id, idmap => { }));
mapper.Subclass<Inherited>(map =>
{
map.Join("MyClassSplit1", mj =>
{
mj.Property(x => x.SomethingA1);
mj.Property(x => x.SomethingA2);
});
map.Join("MyClassSplit2", mj =>
{
mj.Property(x => x.SomethingB1);
mj.Property(x => x.SomethingB2);
});
map.Property(x => x.Something0);
});
var hbmDoc = mapper.CompileMappingFor(new[] { typeof(Inherited) });
var hbmClass = hbmDoc.SubClasses[0];
hbmClass.Joins.Select(j => j.table).Should().Have.SameValuesAs("MyClassSplit1", "MyClassSplit2");
hbmClass.Properties.Single().Name.Should().Be("Something0");
var hbmSplit1 = hbmClass.Joins.Single(j => "MyClassSplit1" == j.table);
hbmSplit1.Properties.Select(p => p.Name).Should().Have.SameValuesAs("SomethingA1", "SomethingA2");
var hbmSplit2 = hbmClass.Joins.Single(j => "MyClassSplit2" == j.table);
hbmSplit2.Properties.Select(p => p.Name).Should().Have.SameValuesAs("SomethingB1", "SomethingB2");
}
示例7: WhenRegisterSubclassWithNoRootThenThrows
public void WhenRegisterSubclassWithNoRootThenThrows()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
inspector.Executing(x => x.IsTablePerClassHierarchy(typeof(Inherited1))).Throws<MappingException>();
}
示例8: WhenRegisteredAsComponentThenIsRegistered
public void WhenRegisteredAsComponentThenIsRegistered()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsComponent(typeof(MyComponent));
Assert.That(inspector.IsComponent(typeof(MyComponent)), Is.True);
}
示例9: WhenSplittedPropertiesThenRegister
public void WhenSplittedPropertiesThenRegister()
{
var inspector = new ExplicitlyDeclaredModel();
var mapper = new ModelMapper(inspector);
mapper.Subclass<Inherited>(map =>
{
map.Join("MyClassSplit1", mj =>
{
mj.Property(x => x.SomethingA1);
mj.Property(x => x.SomethingA2);
});
map.Join("MyClassSplit2", mj =>
{
mj.Property(x => x.SomethingB1);
mj.Property(x => x.SomethingB2);
});
map.Property(x => x.Something0);
});
inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<Inherited>.Property(x => x.Something0)).Should().Be.False();
inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<Inherited>.Property(x => x.Something0)).Should().Be.False();
inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<Inherited>.Property(x => x.SomethingA1)).Should().Be.True();
inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<Inherited>.Property(x => x.SomethingA2)).Should().Be.True();
inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<Inherited>.Property(x => x.SomethingB1)).Should().Be.True();
inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<Inherited>.Property(x => x.SomethingB2)).Should().Be.True();
}
示例10: WhenRegisteredAsComponetThenCantRegisterAsRootEntity
public void WhenRegisteredAsComponetThenCantRegisterAsRootEntity()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsComponent(typeof(MyComponent));
Assert.That(() => inspector.AddAsRootEntity(typeof(MyComponent)), Throws.TypeOf<MappingException>());
}
示例11: WhenMapSplittedPropertiesThenEachPropertyIsInItsSplitGroup
public void WhenMapSplittedPropertiesThenEachPropertyIsInItsSplitGroup()
{
var inspector = new ExplicitlyDeclaredModel();
var mapper = new ModelMapper(inspector);
mapper.Class<MyClass>(map =>
{
map.Id(x => x.Id, idmap => { });
map.Join("MyClassSplit1", mj =>
{
mj.Property(x => x.SomethingA1);
mj.Property(x => x.SomethingA2);
});
map.Join("MyClassSplit2", mj =>
{
mj.Property(x => x.SomethingB1);
mj.Property(x => x.SomethingB2);
});
map.Property(x => x.Something0);
});
var hbmDoc = mapper.CompileMappingFor(new[] { typeof(MyClass) });
var hbmClass = hbmDoc.RootClasses[0];
Assert.That(hbmClass.Joins.Select(j => j.table), Is.EquivalentTo(new [] {"MyClassSplit1", "MyClassSplit2"}));
Assert.That(hbmClass.Properties.Single().Name, Is.EqualTo("Something0"));
var hbmSplit1 = hbmClass.Joins.Single(j => "MyClassSplit1" == j.table);
Assert.That(hbmSplit1.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"SomethingA1", "SomethingA2"}));
var hbmSplit2 = hbmClass.Joins.Single(j => "MyClassSplit2" == j.table);
Assert.That(hbmSplit2.Properties.Select(p => p.Name), Is.EquivalentTo(new [] {"SomethingB1", "SomethingB2"}));
}
示例12: WhenRegisteredAsComponetThenCantRegisterAsUnionSubclass
public void WhenRegisteredAsComponetThenCantRegisterAsUnionSubclass()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsComponent(typeof(MyComponent));
inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(MyComponent))).Throws<MappingException>();
}
示例13: WhenRegisteredAsRootThenDoesNotRegisterTheStrategy
public void WhenRegisteredAsRootThenDoesNotRegisterTheStrategy()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsRootEntity(typeof(MyClass));
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
}
示例14: WhenRegisteredAsSubclassThenIsEntity
public void WhenRegisteredAsSubclassThenIsEntity()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsRootEntity(typeof(MyClass));
inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
Assert.That(inspector.IsEntity(typeof(Inherited1)), Is.True);
}
示例15: WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass
public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass()
{
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsRootEntity(typeof(MyClass));
inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
}