Esempio n. 1
0
        public void IndexDbRef_Order()
        {
            File.Delete(@"c:\temp\dbf.db");

            using (var db = new Hospital())
            {
                var w1 = new Ward { Id = 1, Name = "Ward 1" };
                var w2 = new Ward { Id = 2, Name = "Ward 2" };

                var p1 = new Patient { Id = 1, Name = "John", Ward = w1 };
                var p2 = new Patient { Id = 2, Name = "Dooe", Ward = w1 };
                var p3 = new Patient { Id = 3, Name = "Jona", Ward = w2 };

                db.Patients.EnsureIndex(x => x.Ward.Id);

                db.Wards.Insert(new Ward[] { w1, w2 });
                db.Patients.Insert(new Patient[] { p1, p2, p3 });

                var query = db.Patients
                    .Include(x => x.Ward)
                    .Find(x => x.Ward.Id == 1)
                    //.Find(Query.EQ("Ward.$id", 1))
                    .ToArray();

                Assert.AreEqual(2, query.Count());
            }
        }