Skip to content

Query translation exception #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
letarak opened this issue Mar 3, 2023 · 2 comments
Open

Query translation exception #306

letarak opened this issue Mar 3, 2023 · 2 comments
Assignees

Comments

@letarak
Copy link

letarak commented Mar 3, 2023

DO 7.0

\\ OK
_ = Query.All<Entity>()
  .Select(it => Storage.All<Entity>()
      .Select(e => e.NullableDateTime ?? DateTime.MinValue)
      .FirstOrDefault())
  .ToArray();

\\ OK
_ = Query.All<Entity>()
  .Select(it => (Storage.All<Entity>()
      .Select(e => e.NullableDateTime)
      .FirstOrDefault() ?? DateTime.MinValue)
      .Date)
  .ToArray();

\\ FAIL
_ = Query.All<Entity>()
  .Select(it => Storage.All<Entity>()
      .Select(e => e.NullableDateTime)
      .FirstOrDefault()
      .Value
      .Date)
  .ToArray();

\\ FAIL
_ = Query.All<Entity>()
  .Select(it => Storage.All<Entity>()
      .Select(e => e.NullableDateTime ?? DateTime.MinValue)
      .FirstOrDefault()
      .Date)
  .ToArray();

\\ FAIL
_ = Query.All<Entity>()
  .Select(it => Storage.All<Entity>()
      .Select(e => e.NullableDateTime.Value)
      .FirstOrDefault()
      .Date)
  .ToArray();
@alex-kulakov
Copy link
Contributor

Hello @letarak, do they fail with some exception?

@alex-kulakov alex-kulakov self-assigned this Mar 9, 2023
@letarak
Copy link
Author

letarak commented Mar 12, 2023

Unable to translate 'Query.All().Select(it => Query.All().Select(e => e.LastLoginTime.Value).FirstOrDefault().Date)' expression. See inner exception for details.

Object reference not set to an instance of an object.

 at Xtensive.Orm.Linq.Expressions.MarkerExpression..ctor(Expression target, MarkerType markerType) in /_/Orm/Xtensive.Orm/Orm/Linq/Expressions/MarkerExpression.cs:line 28
   at Xtensive.Orm.Linq.Translator.GetMember(Expression expression, MemberInfo member, Expression sourceExpression) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs:line 1410
   at Xtensive.Orm.Linq.Translator.VisitMemberAccess(MemberExpression ma) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs:line 380
   at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e) in /_/Orm/Xtensive.Orm/Linq/ExpressionVisitor{TResult}.cs:line 125
   at Xtensive.Orm.Linq.Translator.VisitLambda(LambdaExpression le) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs:line 145
   at Xtensive.Orm.Linq.Translator.BuildProjection(LambdaExpression le) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs:line 1367
   at Xtensive.Orm.Linq.Translator.VisitSelect(Expression expression, LambdaExpression le) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs:line 1355
   at Xtensive.Orm.Linq.Translator.VisitQueryableMethod(MethodCallExpression mc, QueryableMethodKind methodKind) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs:line 230
   at Xtensive.Linq.QueryableVisitor.VisitMethodCall(MethodCallExpression mc) in /_/Orm/Xtensive.Orm/Linq/QueryableVisitor.cs:line 33
   at Xtensive.Orm.Linq.Translator.VisitMethodCall(MethodCallExpression mc) in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs:line 519
   at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e) in /_/Orm/Xtensive.Orm/Linq/ExpressionVisitor{TResult}.cs:line 125
   at Xtensive.Orm.Linq.Translator.Translate() in /_/Orm/Xtensive.Orm/Orm/Linq/Translator.Materialization.cs:line 32
   at Xtensive.Orm.Linq.QueryProvider.Translate(Expression expression, CompilerConfiguration compilerConfiguration) in /_/Orm/Xtensive.Orm/Orm/Linq/QueryProvider.cs:line 168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants