コード例 #1
0
 // TODO:
 public static bool ColumnExists(SQLiteSession session, string tableName, string columnName)
 {
     using (var command = session.CreateCommand($"PRAGMA TABLE_INFO({tableName})")) {
         using (var reader = command.ExecuteReader()) {
             while (reader.Read())
             {
                 var name = reader.GetString(1);
                 if (String.Equals(name, columnName, StringComparison.OrdinalIgnoreCase))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #2
0
 // TODO:
 /// <summary>
 /// Sets the user-defined file version of the sqlite db.
 /// You may need to commit afterward.
 /// </summary>
 public static void SetFileVersion(SQLiteSession session, int version)
 {
     using (var command = session.CreateCommand($@"PRAGMA user_version = {version}")) {
         command.ExecuteNonQuery();
     }
 }
コード例 #3
0
 // TODO:
 /// <summary>
 /// Gets the user-defined file version of the sqlite db.
 /// </summary>
 public static int GetFileVersion(SQLiteSession session)
 {
     using (var command = session.CreateCommand("PRAGMA user_version")) {
         return(Convert.ToInt32(command.ExecuteScalar()));
     }
 }
コード例 #4
0
 // TODO:
 public static void ExecuteDdl(SQLiteSession session, string ddl)
 {
     using (var command = session.CreateCommand(ddl)) {
         command.ExecuteNonQuery();
     }
 }