CSLA.NET-Child_Fetch未按预期工作

本文关键字:工作 NET-Child Fetch CSLA | 更新日期: 2023-09-27 18:27:47

我最近在http://forums.lhotka.net/,但我没有得到回应。希望我在这里运气更好。这是我的问题。

我使用的是CSLA.NET4.5,最近我向BusinessBase添加了一个额外的Child_Update方法,以支持其批量保存的ParentBusinessListBase。然而,这似乎在我们的系统中引入了一个错误。看起来,如果您有两个Child_Update方法,其中一个是无参数的,那么将不会调用无参数的方法。即使指定DataPortal.UpdateChild时除了Child对象之外没有其他参数。

伪代码示例:

public class SomeChild : BusinessBase<SomeChild>
{
    //No longer called
    private void Child_Update() {}
    //Newly added
    private void Child_Update(SomeNewParent parent) {}
}
public class SomeLegacyParent : BusinessBase<SomeLegacyParent>
{
    private static readonly PropertyInfo<SomeChild> SomeChildProperty =
        RegisterProperty<SomeChild>(x => x.SomeChild, RelationshipTypes.Child);
    public SomeChild SomeChild
    {
        get { return GetProperty(SomeChildProperty); }
        set { SetProperty(SomeChildProperty, value); }
    }
    //Use to call Child_Update(), but now
    //calls Child_Update(SomeNewParent parent)
    DataPortal.UpdateChild(ReadProperty(SomeChildProperty));
}
public class SomeNewParent : BusinessBase<SomeNewParent>
{
    private static readonly PropertyInfo<SomeChild> SomeChildProperty =
        RegisterProperty<SomeChild>(x => x.SomeChild, RelationshipTypes.Child);
    public SomeChild SomeChild
    {
        get { return GetProperty(SomeChildProperty); }
        set { SetProperty(SomeChildProperty, value); }
    }
    //Calls Child_Update(SomeNewParent parent) --- as expected
    DataPortal.UpdateChild(ReadProperty(SomeChildProperty), this);
}

现在我知道CSLA使用反射来找到要调用的正确数据访问方法,但我不确定为什么根据传递给DataPortal.UpdateChild的参数,无参数方法与参数化方法无法区分?这可能是CSLA漏洞,还是我遗漏了什么?

CSLA.NET-Child_Fetch未按预期工作

嗯,我怀疑这可能是Csla中的一个错误。尝试将Child_Update()更改为Child_Update(SomeLegacyParent),这样您就不再有无参数的Child_Update。您可能必须更改对UpdateChild的旧版父级调用才能传递"this"。

编辑:根据此回复评论中链接到的线程,此问题已在Csla中修复。