/// <summary> /// データ登録 /// </summary> /// <param name="query">SQL文字列</param> /// <param name="args">パラメータ</param> /// <returns>True:正常終了 / False:エラー</returns> public static int Save(string query, params SQLiteParameter[] args) { using (var connector = new SqliteConnector()) using (var command = new SQLiteCommand(query, connector.Connection)) { SqliteCommander.SetParameters(command, args); connector.Open(); int result = 0; using (var tran = new TransactionScope()) { result = command.ExecuteNonQuery(); if (0 < result) { tran.Complete(); } } connector.Close(); return(result); } }
/// <summary> /// データ登録 /// </summary> /// <param name="queries"></param> /// <returns></returns> public static int Save(List <string> queries) { int affectedRow = 0; foreach (string query in queries) { affectedRow += SqliteCommander.Save(query); } return(affectedRow); }
/// <summary> /// 単一行取得 /// </summary> /// <param name="query">SQL文字列</param> /// <param name="args">パラメータ</param> /// <returns>件数</returns> public static int Scalor(string query, params SQLiteParameter[] args) { using (var connector = new SqliteConnector()) using (var command = new SQLiteCommand(query, connector.Connection)) { SqliteCommander.SetParameters(command, args); connector.Open(); int count = (int)command.ExecuteScalar(); connector.Close(); return(count); } }
public static DataTable Select(string query, params SQLiteParameter[] args) { using (var connector = new SqliteConnector()) using (var command = new SQLiteCommand(query, connector.Connection)) { SqliteCommander.SetParameters(command, args); using (var adapt = new SQLiteDataAdapter(command)) { var table = new DataTable(); adapt.Fill(table); return(table); } } }
/// <summary> /// データ削除 /// </summary> public static int Delete(string query, params SQLiteParameter[] args) { return(SqliteCommander.Save(query, args)); }
/// <summary> /// データ削除 /// </summary> public static int Delete(List <string> queries) { return(SqliteCommander.Save(queries)); }