NullReferenceException with self generated Expression Tree #1202
Closed
Description
I get a NullReferenceException with a self generated Select expression tree. I also generate some Null-Checks but I dont know (after some hours of debugging), which part of my expression tree triggers the exception. Can you handle this case and add a meaningful exception message for better debug purposes?
Unhandled Exception: NullReferenceException
System.NullReferenceException: Object reference not set to an instance of an object.
at LinqToDB.Linq.Builder.SelectContext.BuildExpression(Expression expression, Int32 level, Boolean enforceServerSide)
at LinqToDB.Linq.Builder.SelectContext.BuildExpression(Expression expression, Int32 level, Boolean enforceServerSide)
at LinqToDB.Linq.Builder.ExpressionBuilder.TransformExpression(IBuildContext context, Expression expr, Boolean enforceServerSide)
at LinqToDB.Linq.Builder.ExpressionBuilder.<>c__DisplayClass72_0.<BuildExpression>b__0(Expression expr)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Expressions.Extensions.<>c__DisplayClass34_1.<Transform>b__1(MemberBinding b)
at LinqToDB.Expressions.Extensions.Transform2[T](ICollection`1 source, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Expressions.Extensions.<>c__DisplayClass34_1.<Transform>b__1(MemberBinding b)
at LinqToDB.Expressions.Extensions.Transform2[T](ICollection`1 source, Func`2 func)
at LinqToDB.Expressions.Extensions.Transform(Expression expr, Func`2 func)
at LinqToDB.Linq.Builder.SelectContext.BuildExpression(Expression expression, Int32 level, Boolean enforceServerSide)
at LinqToDB.Linq.Builder.SelectContext.BuildQuery[T](Query`1 query, ParameterExpression queryParameter)
at LinqToDB.Linq.Builder.FirstSingleBuilder.FirstSingleContext.BuildQuery[T](Query`1 query, ParameterExpression queryParameter)
at LinqToDB.Linq.Builder.ExpressionBuilder.Build[T]()
at LinqToDB.Linq.Query`1.CreateQuery(IDataContext dataContext, Expression expr)
at LinqToDB.Linq.Query`1.GetQuery(IDataContext dataContext, Expression& expr)
at LinqToDB.Linq.ExpressionQuery`1.GetQuery(Expression& expression, Boolean cache)
at LinqToDB.Linq.ExpressionQuery`1.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
Environment details
linq2db version: 1.10.2