コード例 #1
0
        private void ApplyDatabaseSchema(IStorage storage,
                                                string databaseScriptFullPath)
        {
            string schemaScript;
            using (StreamReader reader = File.OpenText(databaseScriptFullPath)) {
                schemaScript = reader.ReadToEnd();
            }

            IDbConnection connection = storage.Connect();
            using (var unitOfWork = new SqLiteUnitOfWork(storage.Connect())) {
                unitOfWork.BeginTransaction();
                using (IDbCommand command = connection.CreateCommand()) {
                    command.CommandText = schemaScript;
                    command.ExecuteNonQuery();
                }
                unitOfWork.Commit();
            }
        }
コード例 #2
0
 private int GetDdTablesCount(IStorage sqLiteStorage)
 {
     IDbConnection connection = sqLiteStorage.Connect();
     using (connection.BeginTransaction()) {
         using (IDbCommand command = connection.CreateCommand())
         {
             command.CommandText = "SELECT count(*) FROM sqlite_master WHERE type='table';";
             object result = command.ExecuteScalar();
             Console.WriteLine("Get tables count result \"{0}\"", result);
             return Convert.ToInt32(result);
         }
     }
 }