public static object ExecuteScalar(SQLiteConnection connection, CommandType commandType, string commandText, params SQLiteParameter[] commandParameters) { bool isLock = false; try { LockHelper.EnterReadLock(connection.ConnectionString, timeout); isLock = true; object result = SQLiteHelper.ExecuteScalar(connection, commandType, commandText, commandParameters); return(result); } finally { if (isLock) { LockHelper.ExitReadLock(connection.ConnectionString); } } }
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText) { bool isLock = false; try { LockHelper.EnterReadLock(connectionString, timeout); isLock = true; DataSet result = SQLiteHelper.ExecuteDataset(connectionString, commandType, commandText); return(result); } finally { if (isLock) { LockHelper.ExitReadLock(connectionString); } } }
/// /// 读取数据以后需要自行关闭连接 /// /// /// /// /// public static SQLiteDataReader ExecuteReader(SQLiteConnection connection, CommandType commandType, string commandText) { bool isLock = false; try { LockHelper.EnterReadLock(connection.ConnectionString, timeout); isLock = true; SQLiteDataReader result = SQLiteHelper.ExecuteReader(connection, commandType, commandText); return(result); } finally { if (isLock) { LockHelper.ExitReadLock(connection.ConnectionString); } } }
public static int ExecuteNonQuery(SQLiteTransaction trans, CommandType commandType, string commandText, params SQLiteParameter[] commandParameters) { bool isLock = false; try { //由于使用了 事物 ,所以事务不提交 其实并不会更改文件 //so only get ReadLock //在事务提交时在获取写锁 LockHelper.EnterReadLock(trans.Connection.ConnectionString, timeout); isLock = true; int result = SQLiteHelper.ExecuteNonQuery(trans, commandType, commandText, commandParameters); return(result); } finally { if (isLock) { LockHelper.ExitReadLock(trans.Connection.ConnectionString); } } }