RaveNoX/NHibernate.HierarchyId

Get the next descendant

Closed this issue · 2 comments

your code will generate an error when I try to get a next descendant value.

I change your code to

    public static IProjection GetDescendant(MethodCallExpression methodCallExpression)
    {
        var ishift = 0;
        IProjection property;

        if (methodCallExpression.Object == null)
        {
            property = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();
        }
        else
        {
            property = ExpressionProcessor.FindMemberProjection(methodCallExpression.Object).AsProjection();
            ishift = -1;
        }

        var child1 = ExpressionProcessor.FindValue(methodCallExpression.Arguments[ishift + 1]).ToString();
        //var child2 = ExpressionProcessor.FindValue(methodCallExpression.Arguments[ishift + 2]).ToString();

        var arg2 = ExpressionProcessor.FindValue(methodCallExpression.Arguments[ishift + 2]);
        var child2 = arg2 == null ? null : arg2.ToString();

        return new GetDescendantProjection(property, child1, child2);
    }

now it works

Thank you for reporting, please try to use fixed version

I've tested this error and make a tests.
Error now fixed.