Ejemplo n.º 1
0
        public void Demonstrate_ComplexPersistance()
        {
            var patient = new Patient {
                FirstName = "John",
                LastName = "Doe",
                DateOfBirth = new DateTime(1980, 1, 1),
                Prescriptions = new List<Prescription> {
                    new Prescription {
                        DatePrescribed = DateTime.Now,
                        Medication = "Asprin",
                        Dosage = "200mg",
                        NumberOfRefils = 1000
                    }
                },
                Visits = new List<ProviderVisit> {
                    new ProviderVisit {
                        DateOfVisit = DateTime.Now,
                        ProviderName = "Townsville Healthcare",
                        ProviderNotes = "Patient is a pain in the arse."
                    }
                }
            };

            var session = new MongoSession();
            session.Save(patient);

            var fetched = session.Query<Patient>()
                .Where(x => x.LastName == "Doe");

            Assert.IsNotNull(fetched.First());
        }
Ejemplo n.º 2
0
        public void Demonstrate_SimplePersistance()
        {
            var patient = new Patient {
                FirstName = "John",
                LastName = "Doe",
                DateOfBirth = new DateTime(1980, 1, 1)
            };

            using (var db = Mongo.Create("mongodb://localhost/NoRMSample")) {

                db.GetCollection<Patient>().Save(patient);

                var fetched = db.GetCollection<Patient>()
                    .Find(new { LastName = "Doe" });

                Assert.IsNotNull(fetched.First());
            }
        }