RaveNoX / NHibernate.HierarchyId

Adds support for MS SQL HierarchyId type to NHibernate 3
MIT License
6 stars 9 forks source link

Get the next descendant #2

Closed kidtsui closed 11 years ago

kidtsui commented 11 years ago

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

RaveNoX commented 11 years ago

Thank you for reporting, please try to use fixed version

RaveNoX commented 11 years ago

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