After 5.0-RC DO thows exception on .In() with some conditions. In 5.0-Beta3 not reproduce.

Xtensive.Orm.QueryTranslationException was unhandled
  HResult=-2146233088
  Message=Unable to translate 'Query.All().Where(a => a.Id.In(@.someIds)).Except(Query.All().Select(a => a.Link))' expression. See inner exception for details.
  Source=Xtensive.Orm
  StackTrace:
       at Xtensive.Orm.Linq.QueryProvider.Translate[TResult](Expression expression, CompilerConfiguration compilerConfiguration)
       at Xtensive.Orm.Linq.QueryProvider.Translate[TResult](Expression expression)
       at Xtensive.Orm.Linq.QueryProvider.Execute[TResult](Expression expression)
       at Xtensive.Orm.Linq.Queryable`1.GetEnumerator()
       at TestJoinIn.Program.Main(String[] args) in c:\Users\klekovkin\Documents\Visual Studio 2012\Projects\TestJoinIn\TestJoinIn\Program.cs:line 33
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.InvalidCastException
       HResult=-2147467262
       Message=Unable to cast object of type 'Xtensive.Orm.Rse.Providers.StoreProvider' to type 'Xtensive.Orm.Rse.Providers.JoinProvider'.
       Source=Xtensive.Orm
       StackTrace:
            at Xtensive.Orm.Linq.Translator.VisitExistsAsInclude(Expression source, LambdaExpression predicate, Boolean notExists)
            at Xtensive.Orm.Linq.Translator.VisitExists(Expression source, LambdaExpression predicate, Boolean notExists)
            at Xtensive.Orm.Linq.Translator.VisitContains(Expression source, Expression match, Boolean isRoot)
            at Xtensive.Orm.Linq.Translator.VisitIn(MethodCallExpression mc)
            at Xtensive.Orm.Linq.Translator.VisitMethodCall(MethodCallExpression mc)
            at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
            at Xtensive.Orm.Linq.Translator.Visit(Expression e)
            at Xtensive.Orm.Linq.Translator.VisitLambda(LambdaExpression le)
            at Xtensive.Orm.Linq.Translator.VisitWhere(Expression expression, LambdaExpression le)
            at Xtensive.Orm.Linq.Translator.VisitQueryableMethod(MethodCallExpression mc, QueryableMethodKind methodKind)
            at Xtensive.Linq.QueryableVisitor.VisitMethodCall(MethodCallExpression mc)
            at Xtensive.Orm.Linq.Translator.VisitMethodCall(MethodCallExpression mc)
            at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
            at Xtensive.Orm.Linq.Translator.Visit(Expression e)
            at Xtensive.Orm.Linq.Translator.VisitSequence(Expression sequenceExpression, Expression expressionPart)
            at Xtensive.Orm.Linq.Translator.VisitSequence(Expression sequenceExpression)
            at Xtensive.Orm.Linq.Translator.VisitSetOperations(Expression outerSource, Expression innerSource, QueryableMethodKind methodKind, Type elementType)
            at Xtensive.Orm.Linq.Translator.VisitQueryableMethod(MethodCallExpression mc, QueryableMethodKind methodKind)
            at Xtensive.Linq.QueryableVisitor.VisitMethodCall(MethodCallExpression mc)
            at Xtensive.Orm.Linq.Translator.VisitMethodCall(MethodCallExpression mc)
            at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
            at Xtensive.Orm.Linq.Translator.Visit(Expression e)
            at Xtensive.Orm.Linq.Translator.Translate[TResult]()
            at Xtensive.Orm.Linq.QueryProvider.Translate[TResult](Expression expression, CompilerConfiguration compilerConfiguration)
       InnerException:

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestJoinIn
{
    using Xtensive.Orm;
    using Xtensive.Orm.Configuration;

    public static class Program
    {
        private static void Main(string[] args)
        {
            var dc = new DomainConfiguration("sqlserver://localhost/DO40-Tests");

            dc.Types.Register(typeof(Entity2));
            dc.Types.Register(typeof(Entity1));

            dc.UpgradeMode = DomainUpgradeMode.Recreate;
            var sessionConfiguration = new SessionConfiguration(SessionOptions.AutoActivation);

            using (var domain = Domain.Build(dc))
            {
                using (var session = domain.OpenSession(sessionConfiguration))
                using (var t = session.OpenTransaction())
                {
                    var someIds = new[] { Guid.NewGuid(), Guid.NewGuid() };
                    var query1 = session.Query.All<Entity2>().Where(a => a.Id.In(someIds));
                    var query2 = session.Query.All<Entity1>().Select(a => a.Link);
                    var query3 = query1.Except(query2);
                    foreach (var entity2 in query3)
                    {

                    }

                    t.Complete();
                }
            }
        }
    }

    [HierarchyRoot]
    public class Entity1 : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; private set; }

        [Field]
        public string Name { get; set; }

        [Field]
        public Entity2 Link { get; set; }
    }

    [HierarchyRoot]
    public class Entity2 : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; private set; }

        [Field]
        public string Name { get; set; }
    }
}

asked Jul 24 '14 at 01:14

pil0t's gravatar image

pil0t
207545763


One Answer:

Hello pil0t.

Thank you for your report.

answered Jul 28 '14 at 01:45

Alexey%20Kulakov's gravatar image

Alexey Kulakov
52715

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA