Beispiel #1
0
        public void PolyQueries()
        {
            var stgs = new IStorage[]
            {
                new MemoryStorage(),
                //new PersistedMemoryStorage(),
                new FileSystemStorage("fs"),
                //new EsentStorage("esent"),
                new SqlSeverStorage("server=.;database=overdb;integrated security=true"),
            };

            foreach (var stg in stgs)
            {
                var idx = new Index<Animal, string>(a => a.Sound, keyComparer: StringComparer.OrdinalIgnoreCase);

                using (var db = new Database(stg, indexes: new[] { idx }, idFactory: new GuidIdFactory()))
                {
                    db.Delete(db.GetEnumerable());

                    db.SaveMany(new Animal[]
                    {
                        new Cat(), new Dog(), new Cow(),
                    }.AsEnumerable());

                    var animals = db.Query(idx);
                    Assert.That(animals.Count(), Is.EqualTo(3), "{0} not polymorphic", stg.GetType().Name);
                }
            }
        }