Esempio n. 1
0
        public void Include_on_optional_navigation_One_To_One_dependent_963()
        {
            CreateDatabase963();

            using (var ctx = new MyContext963(_fixture.ServiceProvider))
            {
                ctx.Details.Include(d => d.Targaryen).ToList();
            }
        }
Esempio n. 2
0
        public void Include_on_optional_navigation_Many_To_One_963()
        {
            CreateDatabase963();

            using (var ctx = new MyContext963(_fixture.ServiceProvider))
            {
                ctx.Dragons.Include(d => d.Mother).ToList();
            }
        }
Esempio n. 3
0
        public void Include_on_optional_navigation_One_To_One_principal_963()
        {
            CreateDatabase963();

            using (var ctx = new MyContext963(_fixture.ServiceProvider))
            {
                ctx.Targaryens.Include(t => t.Details).ToList();
            }
        }
Esempio n. 4
0
        public void Join_on_optional_navigation_One_To_Many_963()
        {
            CreateDatabase963();

            using (var ctx = new MyContext963(_fixture.ServiceProvider))
            {
                (from t in ctx.Targaryens
                 join d in ctx.Dragons on t.Id equals d.MotherId
                 select d).ToList();
            }
        }
Esempio n. 5
0
        private void CreateDatabase963()
        {
            using (var context = new MyContext963(_fixture.ServiceProvider))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var drogon = new Dragon {
                    Name = "Drogon"
                };
                var rhaegal = new Dragon {
                    Name = "Rhaegal"
                };
                var viserion = new Dragon {
                    Name = "Viserion"
                };
                var balerion = new Dragon {
                    Name = "Balerion"
                };

                var aerys = new Targaryen {
                    Name = "Aerys II"
                };
                var details = new Details
                {
                    FullName = @"Daenerys Stormborn of the House Targaryen, the First of Her Name, the Unburnt, Queen of Meereen, 
Queen of the Andals and the Rhoynar and the First Men, Khaleesi of the Great Grass Sea, Breaker of Chains, and Mother of Dragons"
                };

                var daenerys = new Targaryen {
                    Name = "Daenerys", Details = details, Dragons = new List <Dragon> {
                        drogon, rhaegal, viserion
                    }
                };
                context.Targaryens.Add(daenerys, aerys);
                context.Dragons.Add(drogon, rhaegal, viserion, balerion);
                context.Details.Add(details);

                context.SaveChanges();
            }
        }