2

Closed

Bug with creating arrays

description

When sending a query using contains, an exception is raised. The problem appears to be here:
 
    /// <summary>
    /// Visits a <see cref="SerializableNewArrayExpression"/>.
    /// </summary>
    /// <param name="expression"><see cref="SerializableNewArrayExpression"/> to visit.</param>
    /// <returns>Returns the converted <see cref="Expression"/>.</returns>
    protected override Expression VisitSerializableNewArrayExpression( SerializableNewArrayExpression expression ) {
        if( expression.NodeType == ExpressionType.NewArrayBounds ) {
            return Expression.NewArrayBounds( (Type) expression.Type.GetClrVersion(), VisitCollection<Expression>( expression.Expressions ) );
        }
        return Expression.NewArrayInit( (Type) expression.Type.GetClrVersion(), VisitCollection<Expression>( expression.Expressions ) );
    }
 
And seems to be fixed by using the GetElementType() of the CLR Type thus:
 
    /// <summary>
    /// Visits a <see cref="SerializableNewArrayExpression"/>.
    /// </summary>
    /// <param name="expression"><see cref="SerializableNewArrayExpression"/> to visit.</param>
    /// <returns>Returns the converted <see cref="Expression"/>.</returns>
    protected override Expression VisitSerializableNewArrayExpression( SerializableNewArrayExpression expression ) {
        if( expression.NodeType == ExpressionType.NewArrayBounds ) {
            return Expression.NewArrayBounds(((Type)expression.Type.GetClrVersion()).GetElementType(), VisitCollection<Expression>(expression.Expressions));
        }
        return Expression.NewArrayInit(((Type)expression.Type.GetClrVersion()).GetElementType(), VisitCollection<Expression>(expression.Expressions));
    }
 
Thanks,
Mark.
Closed Aug 28, 2009 at 8:13 PM by Winston_Smith
Is resolved and tested with the Unit-Test Array_01_Static:var employeesQuery = from e in companyExampleContext.Employees select new { Name = e.Name, StaticArray = new[] { "oak", "fir", "spruce", "alder" } };Assert.AreEqual(13, employeesQuery.Count());Assert.AreEqual("oak", employeesQuery.ToList()[1].StaticArray[0]);

comments

tjschnackertz wrote May 27, 2009 at 3:40 PM

Thanks, this fixed my issue using InterLinq with DevX grid.

wrote Aug 28, 2009 at 8:13 PM

wrote Feb 14, 2013 at 2:02 AM

wrote May 16, 2013 at 7:23 AM