Пример #1
0
        public void Import_Paf_File()
        {
            var sqlCOnnection = new SqlConnection(@"Data Source=.\sql2005;Initial Catalog=PAF;Integrated Security=True");
            sqlCOnnection.Open();
            var command = new SqlCommand("Select Top 1000000 FullPostcode, SingleLineAddress FROM ExpandedAddress", sqlCOnnection);
            var reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            var count = 0;

                using (var documentDb2 = new DocSharp(DbName))
                {
                    while (reader.Read())
                    {
                        Console.WriteLine(count);

                        var address = new Address()
                                            {
                                                SingleLineAddress = (string) reader["SingleLineAddress"],
                                                PostCode = (string) reader["FullPostcode"]
                                            };
                        documentDb2.Store(address);
                        count++;
                    }
                }
            reader.Close();

            using (var documentDb2 = new DocSharp(DbName))
            {
                var docFound = new Document<Address>();
                Console.WriteLine(documentDb2.All<Address>().Count());
                Timer(() => docFound = documentDb2.All<Address>().First(q => q.Data.PostCode == "CH46 6HU"));
                Timer(() => docFound = documentDb2.All<Address>().First(q => q.Data.PostCode == "CH46 6HU"));
                Timer(() => docFound = documentDb2.All<Address>().First(q => q.Data.PostCode == "CH46 6HU"));
                Console.Write(docFound.Data.SingleLineAddress);
            }
        }
Пример #2
0
        public void Should_Retrieve_all_objects_of_a_type()
        {
            using (var documentDb = new DocSharp(DbName))
            {
                documentDb.Store(new Company { Name = "My Company 1" });
                documentDb.Store(new Company { Name = "My Company 2" });
                documentDb.Store(new Company { Name = "My Company 3" });
                documentDb.Store(new Contact { FirstName = "Bob", Surname = "Smith" });
                documentDb.Store(new Contact { FirstName = "Bob", Surname = "Smith2" });
            }

            using (var documentDb = new DocSharp(DbName))
            {
                var startTime = DateTime.Now;
                Assert.AreEqual(documentDb.All<Company>().Count(), 3);
                Assert.AreEqual(documentDb.All<Contact>().Count(), 2);
                Console.WriteLine("Time - " + DateTime.Now.Subtract(startTime).TotalMilliseconds);
            }
        }