Example #1
0
        public void Intialize_With_Injected_Context()
        {
            var cache = new PGCache(_connectionStringName);

            _clientStore = new PGStore <Client>(cache);
            Assert.True(_clientStore != null && _clientStore.Cache.DbTableNames.Count > 0);
        }
Example #2
0
        public void PullsThingsDynamically()
        {
            var list    = new PGStore <dynamic>(_connectionStringName);
            var results = list.Query(@"select artist.name AS artist_name, track.name, track.unit_price 
                                   from artist inner join 
                                   album on artist.artist_id = album.artist_id inner join
                                   track on album.album_id = track.album_id
                                   where (artist.name = @0)", "AC/DC");

            Assert.True(results.Count() > 0);
        }
Example #3
0
        public void IBiggyStore_Deletes_Many_Records_With_String_PK()
        {
            IBiggyStore<Widget> widgetStore = new PGStore<Widget>(_connectionStringName);
              var insertThese = new List<Widget>();

              for (int i = 0; i < 10; i++) {
            var newWidget = new Widget() { SKU = "SKU " + i, Name = "Widget " + i, Price = Decimal.Parse(i.ToString()) };
            insertThese.Add(newWidget);
              }
              widgetStore.Add(insertThese);
              var newWidgets = widgetStore.Load();
              int insertedCount = newWidgets.Count();

              widgetStore.Remove(newWidgets);
              newWidgets = widgetStore.Load();
              Assert.True(insertedCount == 10 && newWidgets.Count() == 0);
        }
Example #4
0
        public void IBiggyStore_Deletes_Many_Records_With_String_PK()
        {
            IBiggyStore <Widget> widgetStore = new PGStore <Widget>(_connectionStringName);
            var insertThese = new List <Widget>();

            for (int i = 0; i < 10; i++)
            {
                var newWidget = new Widget()
                {
                    SKU = "SKU " + i, Name = "Widget " + i, Price = Decimal.Parse(i.ToString())
                };
                insertThese.Add(newWidget);
            }
            widgetStore.Add(insertThese);
            var newWidgets    = widgetStore.Load();
            int insertedCount = newWidgets.Count();

            widgetStore.Remove(newWidgets);
            newWidgets = widgetStore.Load();
            Assert.True(insertedCount == 10 && newWidgets.Count() == 0);
        }
Example #5
0
        public static void Run()
        {
            var sw = new Stopwatch();
              var _myDatabase = new PGCache("chinookPG");

              Console.WriteLine("===========================================================");
              Console.WriteLine("POSTGRES DOCUMENTS - INSERT A BUNCH OF DOCUMENTS");
              Console.WriteLine("===========================================================");

              // Build a table to play with from scratch each time:
              if(_myDatabase.TableExists("ClientDocuments")) {
            _myDatabase.DropTable("\"ClientDocuments\"");
              }

              IBiggyStore<ClientDocument> clientDocStore = new PGDocumentStore<ClientDocument>(_myDatabase);
              IBiggy<ClientDocument> clientDocs = new BiggyList<ClientDocument>(clientDocStore);
              int INSERT_MODEST_QTY = 10000;

              Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY);
              var addThese = new List<ClientDocument>();
              for(int i = 0; i < INSERT_MODEST_QTY; i++)
              {
            addThese.Add(new ClientDocument {
              LastName = "Atten",
              FirstName = "John",
              Email = "*****@*****.**"
            });
              }
              sw.Start();
              clientDocs.Add(addThese);
              sw.Stop();
              Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds);

              Console.WriteLine("===========================================================");
              Console.WriteLine("POSTGRES DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF");
              Console.WriteLine("===========================================================");

              // Start clean with no existing table:
              if (_myDatabase.TableExists("ArtistWithAlbums")) {
            _myDatabase.DropTable("\"ArtistWithAlbums\"");
              }

              Console.WriteLine("Retreive artists, albums, and tracks from Db...");
              sw.Reset();
              sw.Start();
              IBiggyStore<Artist> _artistStore = new PGStore<Artist>(_myDatabase);
              IBiggyStore<Album> _albumStore = new PGStore<Album>(_myDatabase);
              IBiggyStore<Track> _trackStore = new PGStore<Track>(_myDatabase);

              IBiggy<Artist> _artists = new BiggyList<Artist>(_artistStore);
              IBiggy<Album> _albums = new BiggyList<Album>(_albumStore);
              IBiggy<Track> _tracks = new BiggyList<Track>(_trackStore);
              sw.Stop();

              Console.WriteLine("Query each artists albums and write to complex document store...");

              var list = new List<ArtistWithAlbums>();
              foreach (var artist in _artists) {
            var artistAlbums = from a in _albums
                           where a.ArtistId == artist.ArtistId
                           select a;
            var newArtistWithAlbums = new ArtistWithAlbums() {
              ArtistId = artist.ArtistId,
              Name = artist.Name,
              Albums = artistAlbums.ToList()
            };
            list.Add(newArtistWithAlbums);
              }

              var docStore = new PGDocumentStore<ArtistWithAlbums>(_myDatabase);
              var artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore);
              artistWithAlbumsDocuments.Add(list);

              sw.Stop();
              Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Retreive artists and albums from Complex document store and hydrate");

              sw.Reset();
              sw.Start();
              artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore);
              sw.Stop();

              int artistCount = artistWithAlbumsDocuments.Count();
              int albumsCount = 0;
              foreach (var artist in artistWithAlbumsDocuments) {
            albumsCount += artist.Albums.Count();
              }
              Console.WriteLine("\tRetreived and Re-Hydrated {0} Artist + {1} Album records from complex documents in {2} ms",
            artistCount, albumsCount, sw.ElapsedMilliseconds);
        }
Example #6
0
 public void Intialize_With_Injected_Context()
 {
     var cache = new PGCache(_connectionStringName);
       _clientStore = new PGStore<Client>(cache);
       Assert.True(_clientStore != null && _clientStore.Cache.DbTableNames.Count > 0);
 }
Example #7
0
 public void Intialize_With_Connection_String_Name()
 {
     _clientStore = new PGStore<Client>(_connectionStringName);
       Assert.True(_clientStore != null && _clientStore.Cache.DbTableNames.Count > 0);
 }
Example #8
0
 public void PullsThingsDynamically()
 {
     var list = new PGStore<dynamic>(_connectionStringName);
       var results = list.Query(@"select artist.name AS artist_name, track.name, track.unit_price
                            from artist inner join
                            album on artist.artist_id = album.artist_id inner join
                            track on album.album_id = track.album_id
                            where (artist.name = @0)", "AC/DC");
       Assert.True(results.Count() > 0);
 }
Example #9
0
 public void Intialize_With_Connection_String_Name()
 {
     _clientStore = new PGStore <Client>(_connectionStringName);
     Assert.True(_clientStore != null && _clientStore.Cache.DbTableNames.Count > 0);
 }
Example #10
0
        public static void Run()
        {
            var sw          = new Stopwatch();
            var _myDatabase = new PGCache("chinookPG");

            Console.WriteLine("===========================================================");
            Console.WriteLine("POSTGRES DOCUMENTS - INSERT A BUNCH OF DOCUMENTS");
            Console.WriteLine("===========================================================");


            // Build a table to play with from scratch each time:
            if (_myDatabase.TableExists("ClientDocuments"))
            {
                _myDatabase.DropTable("\"ClientDocuments\"");
            }

            IBiggyStore <ClientDocument> clientDocStore = new PGDocumentStore <ClientDocument>(_myDatabase);
            IBiggy <ClientDocument>      clientDocs     = new BiggyList <ClientDocument>(clientDocStore);
            int INSERT_MODEST_QTY = 10000;

            Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY);
            var addThese = new List <ClientDocument>();

            for (int i = 0; i < INSERT_MODEST_QTY; i++)
            {
                addThese.Add(new ClientDocument {
                    LastName  = "Atten",
                    FirstName = "John",
                    Email     = "*****@*****.**"
                });
            }
            sw.Start();
            clientDocs.Add(addThese);
            sw.Stop();
            Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds);


            Console.WriteLine("===========================================================");
            Console.WriteLine("POSTGRES DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF");
            Console.WriteLine("===========================================================");

            // Start clean with no existing table:
            if (_myDatabase.TableExists("ArtistWithAlbums"))
            {
                _myDatabase.DropTable("\"ArtistWithAlbums\"");
            }

            Console.WriteLine("Retreive artists, albums, and tracks from Db...");
            sw.Reset();
            sw.Start();
            IBiggyStore <Artist> _artistStore = new PGStore <Artist>(_myDatabase);
            IBiggyStore <Album>  _albumStore  = new PGStore <Album>(_myDatabase);
            IBiggyStore <Track>  _trackStore  = new PGStore <Track>(_myDatabase);

            IBiggy <Artist> _artists = new BiggyList <Artist>(_artistStore);
            IBiggy <Album>  _albums  = new BiggyList <Album>(_albumStore);
            IBiggy <Track>  _tracks  = new BiggyList <Track>(_trackStore);

            sw.Stop();

            Console.WriteLine("Query each artists albums and write to complex document store...");

            var list = new List <ArtistWithAlbums>();

            foreach (var artist in _artists)
            {
                var artistAlbums = from a in _albums
                                   where a.ArtistId == artist.ArtistId
                                   select a;
                var newArtistWithAlbums = new ArtistWithAlbums()
                {
                    ArtistId = artist.ArtistId,
                    Name     = artist.Name,
                    Albums   = artistAlbums.ToList()
                };
                list.Add(newArtistWithAlbums);
            }

            var docStore = new PGDocumentStore <ArtistWithAlbums>(_myDatabase);
            var artistWithAlbumsDocuments = new BiggyList <ArtistWithAlbums>(docStore);

            artistWithAlbumsDocuments.Add(list);

            sw.Stop();
            Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);

            Console.WriteLine("Retreive artists and albums from Complex document store and hydrate");

            sw.Reset();
            sw.Start();
            artistWithAlbumsDocuments = new BiggyList <ArtistWithAlbums>(docStore);
            sw.Stop();

            int artistCount = artistWithAlbumsDocuments.Count();
            int albumsCount = 0;

            foreach (var artist in artistWithAlbumsDocuments)
            {
                albumsCount += artist.Albums.Count();
            }
            Console.WriteLine("\tRetreived and Re-Hydrated {0} Artist + {1} Album records from complex documents in {2} ms",
                              artistCount, albumsCount, sw.ElapsedMilliseconds);
        }