更新日志


IDataBase 弃用两个方法

ExecuteDataReader

ExecuteDataReaderSP

弃用原因:方法的智能不够清晰,容易混淆

IDataBase 新增8个方法

1. 返回 数据集合 List<T>对象

SQL 语句

/// <summary>
/// 执行SQL语句,返回数据集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <param name="action"></param>
/// <returns></returns>
List<T> ExecuteDataList<T>(string sql, IDbParms parameters, Func<DbDataReader, T> action);
/// <summary>
/// 执行SQL语句,返回数据集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
List<T> ExecuteDataList<T>(string sql, IDbParms parameters) where T : new();
GarsonZhang www.yesdotnet.com

存储过程

/// <summary>
/// 执行存储过程,返回数据集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <param name="action"></param>
/// <returns></returns>
List<T> ExecuteDataListSP<T>(string sql, IDbParms parameters, Func<DbDataReader, T> action);

/// <summary>
/// 执行存储过程,返回数据集合
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
List<T> ExecuteDataListSP<T>(string sql, IDbParms parameters) where T : new();
GarsonZhang www.yesdotnet.com

2. 返回 第一条数据 T 对象

 SQL 语句

/// <summary>
/// 执行SQL语句,返回第一行数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <param name="action"></param>
/// <returns></returns>
T ExecuteDataFirst<T>(string sql, IDbParms parameters, Func<DbDataReader, T> action);
/// <summary>
/// 执行SQL语句,返回第一行数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
T ExecuteDataFirst<T>(string sql, IDbParms parameters) where T : new();
GarsonZhang www.yesdotnet.com

存储过程

/// <summary>
/// 执行存储过程,返回第一行数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <param name="action"></param>
/// <returns></returns>
T ExecuteDataFirstSP<T>(string sql, IDbParms parameters, Func<DbDataReader, T> action);
/// <summary>
/// 执行存储过程,返回第一行数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
T ExecuteDataFirstSP<T>(string sql, IDbParms parameters) where T : new();
GarsonZhang www.yesdotnet.com

 

方法调整

调整 DatabaseFactory.CreateDatabase 方法,调整参数位置

原因:使用过程中发现CreateDataBase方法的两个重载,参数有点凌乱

public static IDatabase CreateDatabase(string connectionString, string providerName, Action<DbDataAdapter> CustomerDbDataAdapter)
public static IDatabase CreateDatabase(DbProviderFactory dbProviderFactory, string connectionString, Action<DbDataAdapter> CustomerDbDataAdapter)

如上,ConnectionString 参数 一个在第一个参数位置,另一个又在第二个参数位置,修改 第二个 方法

 

修改前

public static IDatabase CreateDatabase(DbProviderFactory dbProviderFactory, string connectionString, Action<DbDataAdapter> CustomerDbDataAdapter)
GarsonZhang www.yesdotnet.com

修改后

public static IDatabase CreateDatabase(string connectionString, DbProviderFactory dbProviderFactory, Action<DbDataAdapter> CustomerDbDataAdapter)
GarsonZhang www.yesdotnet.com

 

 

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YES开发框架
下一篇:更新日志
评论列表

发表评论

评论内容
昵称:
关联文章