Example #1
0
        public static void Main(string[] args)
        {
            // 1. Create databases.
            var mongodbDatabase = new MongodbDatabase("mongodb://admin(admin):adminpwd0375@localhost:27017/local");
            var mysqlDatabase = new AdoNetDatabase("server=.\\SQLEXPRESS; Database=UniformTest; Trusted_Connection=yes;", SqlServerDialect.Provider);

            // 2. Create database metadata
            var database = UniformDatabase.Create(config => config
                .RegisterDocument<CommentDocument>()
                .RegisterDocument<UserDocument>()
                .RegisterDocument<QuestionDocument>()
                .RegisterDocument<VoteDocument>()
                .RegisterDatabase(SampleDatabases.Mongodb, mongodbDatabase)
                .RegisterDatabase(SampleDatabases.Sql, mysqlDatabase)
            );

            var mydb = new MyDatabase(database);

            database.EnterInMemoryMode();
            mydb.Comments.Save("asdfasdkhafhasldfh", c => { });

            // 3. Optional.
            RunViewModelRegeneration(database);

            var stopwatch = Stopwatch.StartNew();
            database.LeaveInMemoryMode(true);
            stopwatch.Stop();
            Console.WriteLine("Flushed in {0:n0} ms", stopwatch.ElapsedMilliseconds);
            Console.ReadKey();
        }