我正在尝试使用 Habanero Smooth 将两个关系映射到我的 ClassDefs 中定义的类。
哈瓦那平滑等级:
[AutoMapCompulsory]
[AutoMapOneToMany(ReverseRelationshipName = "TestRules")]
public virtual Determinand Determinand
{
get { return Relationships.GetRelatedObject<Determinand>("Determinand"); }
set { Relationships.SetRelatedObject("Determinand", value); }
}
[AutoMapOneToMany(ReverseRelationshipName = "RelatedTestRules")]
public virtual Determinand RelatedDeterminand
{
get { return Relationships.GetRelatedObject<Determinand>("RelatedDeterminand"); }
set { Relationships.SetRelatedObject("RelatedDeterminand", value); }
}
XML 类:
<class name="Determinand" assembly="" table="tbdeterminand" displayName="Determinand">
<property name="DeterminandID" type="Guid" readWriteRule="WriteNew" compulsory="true" />
</class>
问题
当我执行测试以验证我的 ClassDef 是否正确生成时,它失败并给出以下错误:
测试
[Test]
public void Test_ValidateClassDefs()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Add(BOBroker.GetClassDefs());
//---------------Assert Precondition----------------
ClassDef.ClassDefs.ShouldNotBeEmpty();
//---------------Execute Test ----------------------
var validator = new ClassDefValidator(new DefClassFactory());
validator.ValidateClassDefs(ClassDef.ClassDefs);
}
错误
Habanero.Base.Exceptions.InvalidXmlDefinitionException:无法加载关系“RelatedDeterminand”,因为为相关类“Determinand”定义的反向关系“TestRules”和为类“LIMS.BO.TestRule”定义的关系“RelatedDeterminand”确实如此没有与关系键定义相同的属性 - 没有为 RelatedDeterminandID 找到匹配的 RelProp -> DeterminandID 关系相关DeterminandRelProp 1 RelatedDeterminandID - DeterminandID ReverseRelationship TestRulesRelProp 1 DeterminandID - DeterminandID at Habanero.BO.ClassDefinition.ClassDefValidator.CheckReverseRelationshipRelKeyDefProps(IRelationshipDef relationshipDef, IClassDef, StringDef, reverseRelationshipName, IRelationshipDef 反向RelationshipDef,Habanero.BO.ClassDefinition.ClassDefValidator.CheckRelationshipsForAClassDef 的 Habanero.BO.ClassDefinition.ClassDefValidator.CheckRelationshipsForAClassDef(IDictionary`2 loadedFullPropertyLists, IClassDef classDef, ClassDefCol classDefs) 在 Habanero.BO.BO. ClassDefinition.ClassDefValidator.CheckRelationships(ClassDefCol classDefs) at Habanero.BO.ClassDefinition.ClassDefValidator.ValidateClassDefs(ClassDefCol classDefCol) at LIMS.Test.BO.TestClassDefValid.Test_ValidateClassDefs() in TestClassDefValid.cs:第 37 行CheckRelationshipsForAClassDef(IDictionary`2 loadedFullPropertyLists, IClassDef classDef, ClassDefCol classDefs) 在 Habanero.BO.ClassDefinition.ClassDefValidator.CheckRelationships(ClassDefCol classDefs) 在 Habanero.BO.ClassDefinition.ClassDefValidator.ValidateClassDefs(ClassDefCol classDefCol) 在 LIMS.Test.BO.TestClassDefValid。 TestClassDefValid.cs 中的 Test_ValidateClassDefs():第 37 行CheckRelationshipsForAClassDef(IDictionary`2 loadedFullPropertyLists, IClassDef classDef, ClassDefCol classDefs) 在 Habanero.BO.ClassDefinition.ClassDefValidator.CheckRelationships(ClassDefCol classDefs) 在 Habanero.BO.ClassDefinition.ClassDefValidator.ValidateClassDefs(ClassDefCol classDefCol) 在 LIMS.Test.BO.TestClassDefValid。 TestClassDefValid.cs 中的 Test_ValidateClassDefs():第 37 行