public virtual void Repro3101_coalesce_tracking()
        {
            CreateDatabase3101();

            var loggingFactory  = new TestSqlLoggerFactory();
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton <ILoggerFactory>(loggingFactory)
                                  .BuildServiceProvider();

            using (var ctx = new MyContext3101(serviceProvider))
            {
                var query = from eVersion in ctx.Entities
                            join eRoot in ctx.Entities
                            on eVersion.RootEntityId equals(int?) eRoot.Id
                            into RootEntities
                            from eRootJoined in RootEntities.DefaultIfEmpty()
                            select new { eRootJoined, eVersion, foo = eRootJoined ?? eVersion };

                var result = query.ToList();

                var foo = ctx.ChangeTracker.Entries().ToList();
                Assert.True(ctx.ChangeTracker.Entries().Count() > 0);
            }
        }
Beispiel #2
0
        public virtual void Repro3101_simple_coalesce1()
        {
            using (CreateScratch <MyContext3101>(Seed3101))
            {
                using (var ctx = new MyContext3101())
                {
                    var query = from eVersion in ctx.Entities
                                join eRoot in ctx.Entities.Include(e => e.Children).AsNoTracking()
                                on eVersion.RootEntityId equals(int?) eRoot.Id
                                into RootEntities
                                from eRootJoined in RootEntities.DefaultIfEmpty()
                                select eRootJoined ?? eVersion;

                    var result = query.ToList();
                }
            }
        }
Beispiel #3
0
        public virtual void Repro3101_conditional()
        {
            using (CreateScratch <MyContext3101>(Seed3101))
            {
                using (var ctx = new MyContext3101())
                {
                    var query = from eVersion in ctx.Entities.Include(e => e.Children)
                                join eRoot in ctx.Entities
                                on eVersion.RootEntityId equals(int?) eRoot.Id
                                into RootEntities
                                from eRootJoined in RootEntities.DefaultIfEmpty()
                                select eRootJoined != null ? eRootJoined : eVersion;

                    var result = query.ToList();
                    Assert.True(result.All(e => e.Children.Count > 0));
                }
            }
        }
Beispiel #4
0
        public virtual void Repro3101_nested_coalesce2()
        {
            using (CreateScratch <MyContext3101>(Seed3101))
            {
                using (var ctx = new MyContext3101())
                {
                    var query = from eVersion in ctx.Entities.Include(e => e.Children)
                                join eRoot in ctx.Entities
                                on eVersion.RootEntityId equals(int?) eRoot.Id
                                into RootEntities
                                from eRootJoined in RootEntities.DefaultIfEmpty()
                                select new { One = eRootJoined, Two = 2, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) };

                    var result = query.ToList();
                    Assert.True(result.All(e => e.Coalesce.Children.Count > 0));
                }
            }
        }
Beispiel #5
0
        public virtual void Repro3101_complex_coalesce2()
        {
            using (CreateScratch <MyContext3101>(Seed3101))
            {
                using (var ctx = new MyContext3101())
                {
                    var query = from eVersion in ctx.Entities
                                join eRoot in ctx.Entities.Include(e => e.Children)
                                on eVersion.RootEntityId equals(int?) eRoot.Id
                                into RootEntities
                                from eRootJoined in RootEntities.DefaultIfEmpty()
                                select new { Root = eRootJoined, Coalesce = eRootJoined ?? eVersion };

                    var result = query.ToList();
                    Assert.Equal(2, result.Count(e => e.Coalesce.Children.Count > 0));
                }
            }
        }
Beispiel #6
0
        public virtual void Repro3101_coalesce_tracking()
        {
            using (CreateScratch <MyContext3101>(Seed3101))
            {
                using (var ctx = new MyContext3101())
                {
                    var query = from eVersion in ctx.Entities
                                join eRoot in ctx.Entities
                                on eVersion.RootEntityId equals(int?) eRoot.Id
                                into RootEntities
                                from eRootJoined in RootEntities.DefaultIfEmpty()
                                select new { eRootJoined, eVersion, foo = eRootJoined ?? eVersion };

                    var result = query.ToList();

                    Assert.True(ctx.ChangeTracker.Entries().Any());
                }
            }
        }
        public virtual void Repro3101_conditional()
        {
            CreateDatabase3101();

            var loggingFactory  = new TestSqlLoggerFactory();
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton <ILoggerFactory>(loggingFactory)
                                  .BuildServiceProvider();

            using (var ctx = new MyContext3101(serviceProvider))
            {
                var query = from eVersion in ctx.Entities.Include(e => e.Children)
                            join eRoot in ctx.Entities
                            on eVersion.RootEntityId equals(int?) eRoot.Id
                            into RootEntities
                            from eRootJoined in RootEntities.DefaultIfEmpty()
                            select eRootJoined != null ? eRootJoined : eVersion;

                var result = query.ToList();
                Assert.True(result.All(e => e.Children.Count > 0));
            }
        }
        public virtual void Repro3101_nested_coalesce1()
        {
            CreateDatabase3101();

            var loggingFactory  = new TestSqlLoggerFactory();
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton <ILoggerFactory>(loggingFactory)
                                  .BuildServiceProvider();

            using (var ctx = new MyContext3101(serviceProvider))
            {
                var query = from eVersion in ctx.Entities
                            join eRoot in ctx.Entities.Include(e => e.Children)
                            on eVersion.RootEntityId equals(int?) eRoot.Id
                            into RootEntities
                            from eRootJoined in RootEntities.DefaultIfEmpty()
                            select new { One = 1, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) };

                var result = query.ToList();
                Assert.Equal(2, result.Count(e => e.Coalesce.Children.Count > 0));
            }
        }