using System; using System.Collections.Generic; using System.Data; using System.Data.Common; namespace CSFramework.DB { /// /// 数据库接口 /// public interface IDatabase : IAdoFactory, IDbMetalQuery { DatabaseType DatabaseType { get; } int DefaultPort { get; } int CommandTimeout { get; } int ConnectionTimeout { get; } Type DateTimeType { get; } string ConnectionString { get; set; } /// /// MSSQL,Oracle,MySQL数据库类型转换为通用的System.Data.DbType /// /// MSSQL,Oracle,MySQL数据库类型 /// DbType ToDbType(string sourceType); /// /// MSSQL,Oracle,MySQL数据库类型转换为通用的.NET对象类型(Type) /// /// MSSQL,Oracle,MySQL数据库类型 /// Type ToNetType(string sourceType); DateTime GetServerTime(); DbTransaction TransBegin(); void TransCommit(DbTransaction trans, bool closeConnection = false); void TransRollback(DbTransaction trans, bool closeConnection = false); DataSet GetDataSet(string SQL); DataSet GetDataSet(DbCommand cmd); DataSet GetDataSet(string text, CommandType type, IDataParameter[] paras); DataTable GetTable(string SQL, string tableName = ""); /// /// 获取指定记录条数的数据 /// /// 记录条数 /// 表名 /// 字段列表,如:ID,Name,Price /// 查询条件SQL命令参数 /// 排序,如:ID DESC,若有多个排序,参考:ID DESC,Name ASC。注意不能带Order By关键词 /// DataTable GetTop(int top, string tableName, string fields = "", List where = null, string orderBy = ""); DataTable GetTable(DbCommand cmd, string tableName = ""); DataRow GetDataRow(string SQL); int ExecuteSQL(string SQL); int ExecuteCommand(DbCommand cmd); object ExecuteScalar(string SQL); object ExecuteScalar(DbCommand cmd); DbDataReader ExecuteReader(string SQL); DbDataReader ExecuteReader(DbCommand cmd); List ExecuteReader(string SQL, Func action) where T : new(); List ExecuteReader(DbCommand cmd, Func action) where T : new(); List ExecuteReaderList(string SQL) where T : new(); List ExecuteReaderList(DbCommand cmd) where T : new(); List GetStringList(string SQL); List GetStringList(DbCommand cmd); T ExecuteReader(DbCommand cmd) where T : new(); T ExecuteReader(string SQL) where T : new(); int ExecuteTrans(DbTransaction trans, string SQL); int ExecuteTrans(DbTransaction trans, DbCommand cmd); void Close(DbConnection connection); /// /// 返回包含参数符号的参数名称,比如:@Code, :Code, ?p_Code /// /// /// string ParseParamName(string paramName); /// /// 获取当前表最新(最大)的自增字段值 /// /// 表名 /// int GetMaxID(string tableName); bool UpdateDataSet(DataTable ds, string tableName, string KEY); bool InstDataSet(DataTable ds, string tableName); } }