private void GetEntityWithAuditHistoryQuery <T>(InheritanceContext context, IQueryable <T> query)
            where T : Animal
        {
            var queryTypeQuery = context.Set <AnimalQuery>().FromSqlRaw(NormalizeDelimitersInRawString("Select * from [Animals]"));

            var animalQuery = query.Cast <Animal>();

            var joinQuery =
                from animal in animalQuery
                join keylessanimal in queryTypeQuery on animal.Name equals keylessanimal.Name
                select new { animal, keylessanimal };

            var result = joinQuery.ToList();

            Assert.Single(result);
        }
        protected void SeedData(InheritanceContext context)
        {
            var kiwi = new Kiwi
            {
                Species      = "Apteryx haastii",
                Name         = "Great spotted kiwi",
                IsFlightless = true,
                FoundOn      = Island.South
            };

            var eagle = new Eagle
            {
                Species = "Aquila chrysaetos canadensis",
                Name    = "American golden eagle",
                Group   = EagleGroup.Booted
            };

            eagle.Prey.Add(kiwi);

            var rose = new Rose
            {
                Species   = "Rosa canina",
                Name      = "Dog-rose",
                HasThorns = true
            };

            var daisy = new Daisy
            {
                Species = "Bellis perennis",
                Name    = "Common daisy"
            };

            var nz = new Country {
                Id = 1, Name = "New Zealand"
            };

            nz.Animals.Add(kiwi);

            var usa = new Country {
                Id = 2, Name = "USA"
            };

            usa.Animals.Add(eagle);

            context.Set <Animal>().Add(kiwi);
            context.Set <Bird>().Add(eagle);
            context.Set <Country>().Add(nz);
            context.Set <Country>().Add(usa);
            context.Set <Rose>().Add(rose);
            context.Set <Daisy>().Add(daisy);

            context.SaveChanges();
        }
Пример #3
0
 public virtual IQueryable <T> Get()
 {
     return(_context.Set <T>());
 }