You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.5 KiB
72 lines
2.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace Apewer.Source
|
|
{
|
|
|
|
/// <summary>数据库访问接口。</summary>
|
|
public interface IDbClientAdo : IDisposable
|
|
{
|
|
|
|
#region Connection
|
|
|
|
/// <summary>获取连接。</summary>
|
|
IDbConnection Connection { get; }
|
|
|
|
/// <summary>数据库当前在线,表示连接可用。</summary>
|
|
bool Online { get; }
|
|
|
|
/// <summary>连接数据库,若未连接则尝试连接,返回错误信息。</summary>
|
|
string Connect();
|
|
|
|
#endregion
|
|
|
|
#region SQL
|
|
|
|
/// <summary>查询。</summary>
|
|
IQuery Query(string statement);
|
|
|
|
/// <summary>查询。</summary>
|
|
IQuery Query(string statement, IEnumerable<IDataParameter> parameters);
|
|
|
|
/// <summary>执行。</summary>
|
|
IExecute Execute(string statement);
|
|
|
|
/// <summary>执行。</summary>
|
|
IExecute Execute(string statement, IEnumerable<IDataParameter> parameters);
|
|
|
|
// /// <summary>获取当前的事务对象。</summary>
|
|
// IDbTransaction Transaction { get; }
|
|
|
|
#endregion
|
|
|
|
#region Transaction
|
|
|
|
// /// <summary>启动事务。</summary>
|
|
// /// <param name="isolation">事务锁定:默认为快照方式,在完成提交前,其它连接无法获取当前事务挂起的更改。</param>
|
|
// /// <param name="commit">当关闭连接时,提交或回滚未处理的事务。</param>
|
|
// /// <remarks>当存在已经启动的事务时,无法再次启动(返回 NULL 值)。</remarks>
|
|
// string Begin(IsolationLevel isolation = IsolationLevel.Snapshot, bool commit = true);
|
|
|
|
/// <summary>启动事务。</summary>
|
|
/// <param name="commit">当关闭连接时,提交或回滚未处理的事务。</param>
|
|
/// <remarks>当存在已经启动的事务时,无法再次启动(返回 NULL 值)。</remarks>
|
|
string Begin(bool commit = true);
|
|
|
|
/// <summary>提交事务。</summary>
|
|
/// <remarks>异常常见于事务已经提交或连接已断开。</remarks>
|
|
/// <returns>提交失败时返回错误信息,成功时返回 NULL 值。</returns>
|
|
string Commit();
|
|
|
|
/// <summary>从挂起状态回滚事务。</summary>
|
|
/// <remarks>异常常见于事务已经提交、已回滚或连接已断开。</remarks>
|
|
/// <returns>提交失败时返回错误信息,成功时返回 NULL 值。</returns>
|
|
string Rollback();
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|