Example #1
0
        public void Intialize_With_Injected_Context()
        {
            var context = new SQLServerCache(_connectionStringName);

            _sqlStore = new SQLServerStore <Client>(context);
            Assert.True(_sqlStore != null && _sqlStore.Cache.DbTableNames.Count > 0);
        }
Example #2
0
        public void PullsThingsDynamically()
        {
            var list    = new SQLServerStore <dynamic>(_connectionStringName);
            var results = list.Query(@"select Artist.Name AS ArtistName, Track.Name, Track.UnitPrice
                                   from Artist inner join
                                   Album on Artist.ArtistId = Album.ArtistId inner join
                                   Track on Album.AlbumId = Track.AlbumId
                                   where (Artist.Name = @0)", "ac/dc");

            Assert.True(results.Count() > 0);
        }
Example #3
0
        public void Deletes_Range_of_Records_With_Composite_String_PK()
        {
            var list = new List<CompoundWidget>();
              for (int i = 1; i <= 10; i++) {
            var newWidget = new CompoundWidget() { SKU = "SKU " + i, Name = "Widget " + i, Price = Decimal.Parse(i.ToString()) };
            list.Add(newWidget);
              }
              int initialCount = list.Count;
              IBiggyStore<CompoundWidget> cpdWidgetStore = new SQLServerStore<CompoundWidget>(_cache);
              cpdWidgetStore.Add(list);

              var deleteMe = cpdWidgetStore.Load();
              cpdWidgetStore.Remove(deleteMe.ToList());

              var fetchWidgets = cpdWidgetStore.Load();
              Assert.True(initialCount == 10 && fetchWidgets.Count() == 0);
        }
Example #4
0
        public void IBiggyStore_Deletes_Many_Records_With_String_PK()
        {
            IBiggyStore<Widget> widgetStore = new SQLServerStore<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 void IBiggyStore_Deletes_Many_Records_With_String_PK()
        {
            IBiggyStore <Widget> widgetStore = new SQLServerStore <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 #6
0
        public static void Run()
        {
            var sw          = new Stopwatch();
            var _myDatabase = new SQLServerCache("chinook");

            Console.WriteLine("===========================================================");
            Console.WriteLine("SQL SERVER 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 SQLDocumentStore <ClientDocument>("chinook");
            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("SQL SERVER DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF");
            Console.WriteLine("===========================================================");

            // Start clean with no existing table:
            var temp = new SQLServerCache("chinook");

            if (temp.TableExists("ArtistWithAlbums"))
            {
                temp.DropTable("ArtistWithAlbums");
            }


            Console.WriteLine("Retreive artists, albums, and tracks from Db...");
            sw.Reset();
            sw.Start();
            IBiggyStore <Artist> _artistStore = new SQLServerStore <Artist>(_myDatabase);
            IBiggyStore <Album>  _albumStore  = new SQLServerStore <Album>(_myDatabase);
            IBiggyStore <Track>  _trackStore  = new SQLServerStore <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 SQLDocumentStore <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");

            //// Re-hydrate the store, just to be sure:
            //_myDatabase = new SQLServerHost("chinook");

            //sw.Reset();
            //sw.Start();
            //artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore);
            //foreach (var artist in artistWithAlbumsDocuments) {
            //  Console.WriteLine("\t{0}", artist.Name);
            //  var albumNames = from a in artist.Albums select a.Title;
            //  foreach (string name in albumNames) {
            //    string useName = name;
            //    if (name.Length > 10) {
            //      useName = name.Remove(10, name.Length - 10);
            //    }
            //    Console.WriteLine("\t\t{0} ...", useName);
            //  }
            //}
            //sw.Stop();
            //Console.WriteLine("\tRetreived and Re-Hydrated/wrote to console {0} Artist + Album records from complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);
        }
Example #7
0
 public void Intialize_With_Injected_Context()
 {
     var context = new SQLServerCache(_connectionStringName);
       _sqlStore = new SQLServerStore<Client>(context);
       Assert.True(_sqlStore != null && _sqlStore.Cache.DbTableNames.Count > 0);
 }
Example #8
0
 public void Intialize_With_Connection_String_Name()
 {
     _sqlStore = new SQLServerStore<Client>(_connectionStringName);
       Assert.True(_sqlStore != null && _sqlStore.Cache.DbTableNames.Count > 0);
 }
Example #9
0
 public void PullsThingsDynamically()
 {
     var list = new SQLServerStore<dynamic>(_connectionStringName);
       var results = list.Query(@"select Artist.Name AS ArtistName, Track.Name, Track.UnitPrice
                            from Artist inner join
                            Album on Artist.ArtistId = Album.ArtistId inner join
                            Track on Album.AlbumId = Track.AlbumId
                            where (Artist.Name = @0)", "ac/dc");
       Assert.True(results.Count() > 0);
 }
Example #10
0
 public void Intialize_With_Connection_String_Name()
 {
     _sqlStore = new SQLServerStore <Client>(_connectionStringName);
     Assert.True(_sqlStore != null && _sqlStore.Cache.DbTableNames.Count > 0);
 }
Example #11
0
        public static void Run()
        {
            var sw = new Stopwatch();
              var _myDatabase = new SQLServerCache("chinook");

              Console.WriteLine("===========================================================");
              Console.WriteLine("SQL SERVER 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 SQLDocumentStore<ClientDocument>("chinook");
              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("SQL SERVER DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF");
              Console.WriteLine("===========================================================");

              // Start clean with no existing table:
              var temp = new SQLServerCache("chinook");
              if (temp.TableExists("ArtistWithAlbums")) {
            temp.DropTable("ArtistWithAlbums");
              }

              Console.WriteLine("Retreive artists, albums, and tracks from Db...");
              sw.Reset();
              sw.Start();
              IBiggyStore<Artist> _artistStore = new SQLServerStore<Artist>(_myDatabase);
              IBiggyStore<Album> _albumStore = new SQLServerStore<Album>(_myDatabase);
              IBiggyStore<Track> _trackStore = new SQLServerStore<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 SQLDocumentStore<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");

              //// Re-hydrate the store, just to be sure:
              //_myDatabase = new SQLServerHost("chinook");

              //sw.Reset();
              //sw.Start();
              //artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore);
              //foreach (var artist in artistWithAlbumsDocuments) {
              //  Console.WriteLine("\t{0}", artist.Name);
              //  var albumNames = from a in artist.Albums select a.Title;
              //  foreach (string name in albumNames) {
              //    string useName = name;
              //    if (name.Length > 10) {
              //      useName = name.Remove(10, name.Length - 10);
              //    }
              //    Console.WriteLine("\t\t{0} ...", useName);
              //  }
              //}
              //sw.Stop();
              //Console.WriteLine("\tRetreived and Re-Hydrated/wrote to console {0} Artist + Album records from complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);
        }