using System; using System.Collections.Generic; using System.Data; using System.Text; namespace Apewer.Source { /// 数据库访问接口。 public interface IDbClientAdo : IDisposable { #region Connection /// 获取连接。 IDbConnection Connection { get; } /// 数据库当前在线,表示连接可用。 bool Online { get; } /// 连接数据库,若未连接则尝试连接,返回错误信息。 string Connect(); #endregion #region SQL /// 查询。 IQuery Query(string statement); /// 查询。 IQuery Query(string statement, IEnumerable parameters); /// 执行。 IExecute Execute(string statement); /// 执行。 IExecute Execute(string statement, IEnumerable parameters); // /// 获取当前的事务对象。 // IDbTransaction Transaction { get; } #endregion #region Transaction // /// 启动事务。 // /// 事务锁定:默认为快照方式,在完成提交前,其它连接无法获取当前事务挂起的更改。 // /// 当关闭连接时,提交或回滚未处理的事务。 // /// 当存在已经启动的事务时,无法再次启动(返回 NULL 值)。 // string Begin(IsolationLevel isolation = IsolationLevel.Snapshot, bool commit = true); /// 启动事务。 /// 当关闭连接时,提交或回滚未处理的事务。 /// 当存在已经启动的事务时,无法再次启动(返回 NULL 值)。 string Begin(bool commit = true); /// 提交事务。 /// 异常常见于事务已经提交或连接已断开。 /// 提交失败时返回错误信息,成功时返回 NULL 值。 string Commit(); /// 从挂起状态回滚事务。 /// 异常常见于事务已经提交、已回滚或连接已断开。 /// 提交失败时返回错误信息,成功时返回 NULL 值。 string Rollback(); #endregion } }