private static void OpenV4Database()
        {
            Console.WriteLine("Create v4 database");

            var connectionString = EnsureDataDirectory("DatabaseV4.db");

            using (var db = new LiteDBv4.LiteDatabase(connectionString))
            {
                // Get customer collection
                var col = db.GetCollection <Customer>("customers");

                // Create your new customer instance
                var customer = new Customer
                {
                    Name     = "John Doe",
                    Phones   = new[] { "8000-0000", "9000-0000" },
                    Age      = 39,
                    IsActive = true
                };

                // Create unique index in Name field
                // col.EnsureIndex(x => x.Name, true);

                col.Upsert(customer);

                // Use LINQ to query documents (with no index)
                var results = col.Find(x => x.Age > 20);

                // Dump(results.ToList());
            }
        }
Example #2
0
        public static void CreateDatabases()
        {
            Console.WriteLine("Create v4 database");

            using (var db = new LiteDBv4.LiteDatabase(EnsureDataDirectory("DatabaseV4.db")))
            {
                // Get customer collection
                var col = db.GetCollection <Customer>("customers");

                // Create your new customer instance
                var customer = new Customer
                {
                    Name     = "John Doe",
                    Phones   = new string[] { "8000-0000", "9000-0000" },
                    Age      = 39,
                    IsActive = true
                };

                // Create unique index in Name field
                // col.EnsureIndex(x => x.Name, true);

                col.Upsert(customer);

                // Use LINQ to query documents (with no index)
                var results = col.Find(x => x.Age > 20);

                Dump(results.ToList());
            }

            Console.WriteLine();
            Console.WriteLine("Create v5 database");
            using (var db = new LiteDBv5.LiteDatabase(EnsureDataDirectory("DatabaseV5.db")))
            {
                // var jsonInfo = JsonConvert.SerializeObject(LiteDBv5., Formatting.Indented);
                // Get customer collection
                var col = db.GetCollection <Customer>("customers");

                // Create your new customer instance
                var customer = new Customer
                {
                    Name     = "Julian Paulozzi",
                    Phones   = new string[] { "6000-0000", "7000-0000" },
                    Age      = 24,
                    IsActive = false
                };

                // Create unique index in Name field
                // col.EnsureIndex(x => x.Name, true);

                col.Upsert(customer);

                // Use LINQ to query documents (with no index)
                var results = col.Find(x => x.Age > 20);

                Dump(results.ToList());
            }
        }