DO 5.0.7 - normal execution DO 5.0.12 - throw exception

namespace Sample
{
    using System;
    using System.Linq;
    using System.Transactions;
    using Xtensive.Orm;
    using Xtensive.Orm.Configuration;

    class Programy
    {
        static void Main(string[] args)
        {
            var sc = new SessionConfiguration("Default")
            {
                BatchSize = 25,
                DefaultIsolationLevel = IsolationLevel.ReadCommitted,
                CacheSize = 1000,
                DefaultCommandTimeout = 600,
                Options =
                    SessionOptions.Default
                    | SessionOptions.NonTransactionalReads
                    | SessionOptions.AutoActivation
                    | SessionOptions.SuppressRollbackExceptions
            };

            var dc = new DomainConfiguration("sqlserver", @"Data Source=.; Initial Catalog=DO40-Tests; Integrated Security=True;Connection Timeout=5;Application Name=Werp;")
            {
                UpgradeMode = DomainUpgradeMode.Recreate
            };

            dc.Sessions.Add(sc);
            dc.Types.Register(typeof(Item));

            using (var domain = Domain.Build(dc))
            {
                using (var s = domain.OpenSession())
                using (s.Activate())
                using (var t = Session.Current.OpenTransaction())
                {
                    var first = Query.All<Item>().Select(q => new { q.Id, Enum = TestEnum.A });

                    var second = Query.All<Item>().Select(q => new { q.Id, Enum = TestEnum.B });

                    first.Concat(second).FirstOrDefault();

                    t.Complete();
                }
            }
        }
    }

    [HierarchyRoot]
    [Serializable]
    [KeyGenerator(KeyGeneratorKind.None)]
    public class Item : Entity
    {
        public Item(Guid id)
            : base(id)
        {
        }

        [Field]
        [Key]
        public Guid Id { get; }
    }

    public enum TestEnum
    {
        A,
        B
    }
}

Exception:

Unable to translate 'Query.All().Select(q => new @<Id, Enum>(
  q.Id,
  $<TestEnum>(A)
)).Concat(Query.All().Select(q => new @<Id, Enum>(
  q.Id,
  $<TestEnum>(B)
))).FirstOrDefault()' expression. See inner exception for details.

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 System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
at Sample.Programy.Main(String[] args) in D:\Projects\CleanDO\Sample\ProgramTestVersions.cs:line 44
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()

asked Mar 03 at 05:47

Gushchin%20Anton's gravatar image

Gushchin Anton
5122


One Answer:

Hello Anton,

The bug is confirmed. I fixed it in development branch so next version will contain needed changes. Thank you for the report

answered Mar 13 at 08:18

Alexey%20Kulakov's gravatar image

Alexey Kulakov
45215

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