質問

I recently posted this on http://forums.lhotka.net/ , but I'm not getting a response. Hopefully I have better luck here. Here is my problem.

I'm using CSLA .NET 4.5, and I recently added an additional Child_Update method to a BusinessBase to support its Parent BusinessListBase in bulk saving. However, this seemed to of introduced a bug in our system. It looks like if you have two Child_Update methods and one of them is parameterless, the parameterless one won't be called. Even if you specify the DataPortal.UpdateChild with no additional parameters beyond the Child Object.

Example in pseudo code:

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);
}

Now I know CSLA uses Reflection to find the correct data access method to call, however I'm not sure why a parameterless method would not be distinguishable from a parameterized one based on the arguments passed to DataPortal.UpdateChild? Could this be a CSLA bug or am I missing something?

役に立ちましたか?

解決

Hmm, I suspect this could be a bug in Csla. Try changing the Child_Update() to Child_Update(SomeLegacyParent) so you no longer have a parameterless Child_Update. You may have to change the legacy parents call to UpdateChild to pass 'this' as well.

Edit: Per the thread linked to in this answers comments, this issue has been fixed in Csla.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top