/// <summary> /// DataTable 轉換為List 集合 /// </summary> /// <typeparam name="TResult">類型</typeparam> /// <param name="dt">DataTable</param> /// <returns></returns> public static List<TResult> ToList<TResult>(this DataTable dt) where TResult : class,new() /// <summary> /// 轉換為一個DataTable /// </summary> /// <typeparam name="TResult"></typeparam> /// <param name="value"></param> /// <returns></returns> public static DataTable ToDataTable<TResult>(this IEnumerable<TResult> value) where TResult : class 業務邏輯接口 //name:wujc 2013-06-20 namespace Yc.BLL { public class DataDomain : IDataService { private readonly IDataService dal = DataAccess.CreateService(); public DataDomain() { } #region 成員方法 /// <summary> /// 獲取表行數 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="strWhere"></param> /// <returns></returns> public int GetRowsCount<T>(string strWhere) where T : BaseModel, new() { return dal.GetRowsCount<T>(strWhere); } /// <summary> /// 獲取表行數 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sql"></param> /// <returns></returns> public int GetRowsCount(string sql) { return dal.GetRowsCount(sql); } /// <summary> /// 是否存在該記錄 /// </summary> public bool Exists<T>(string id) where T : BaseModel, new() { return dal.Exists<T>(id); } /// <summary> /// 增加一條數據 /// </summary> public bool Add<T>(T model) where T : BaseModel, new() { return dal.Add<T>(model); } /// <summary> /// 增加多條數據 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="modelList"></param> /// <returns></returns> public bool Add<T>(List<T> modelList) where T : BaseModel, new() { return dal.Add<T>(modelList); } /// <summary> /// 更新一條數據 /// </summary> public bool Update<T>(T model) where T : BaseModel, new() { return dal.Update<T>(model); } /// <summary> /// 更新多條數據 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <returns></returns> public bool Update<T>(List<T> modelList) where T : BaseModel, new() { return dal.Update<T>(modelList); } /// <summary> /// 刪除一條數據 /// </summary> public bool Delete<T>(string id) where T : BaseModel, new() { return dal.Delete<T>(id); } /// <summary> /// 刪除一條數據 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="id"></param> /// <returns></returns> public bool Delete<T>(T model) where T : BaseModel, new() { return dal.Delete<T>(model); } /// <summary> /// 刪除多條數據 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <returns></returns> public bool Delete<T>(List<T> modelList) where T : BaseModel, new() { return dal.Delete<T>(modelList); } /// <summary> /// 批量刪除數據 /// </summary> /// <param name="idList">逗號分隔</param> /// <returns></returns> public bool DeleteList<T>(string idList) where T : BaseModel, new() { return dal.DeleteList<T>(idList); } /// <summary> /// 得到一個對象實體 /// </summary> public T GetModel<T>(string id) where T : BaseModel, new() { return dal.GetModel<T>(id); } /// <summary> /// 得到全部對象實體 /// </summary> public List<T> GetModelList<T>(string strWhere) where T : BaseModel, new() { return dal.GetModelList<T>(strWhere); } /// <summary> /// 獲得數據列表 /// </summary> public DataSet GetList<T>(string strWhere) where T : BaseModel, new() { return dal.GetList<T>(strWhere); } /// <summary> /// 獲得數據表 /// </summary> public DataTable GetTable<T>(string strWhere) where T : BaseModel, new() { return dal.GetTable<T>(strWhere); } /// <summary> /// 根據分頁獲得數據列表 /// </summary> public DataSet GetList<T>(string strWhere, string orderby, int startIndex, int endIndex) where T : BaseModel, new() { return dal.GetList<T>(strWhere, orderby, startIndex, endIndex); } /// <summary> /// 根據分頁獲得數據列表 /// </summary> public DataSet GetListBySql(string sql, string orderby, int startIndex, int endIndex) { return dal.GetListBySql(sql, orderby, startIndex, endIndex); } /// <summary> /// 執行SQL語句,返回影響的記錄數 /// </summary> /// <param name="SQLString">SQL語句</param> /// <returns>影響的記錄數</returns> public int ExecuteSql(string SQLString) { return dal.ExecuteSql(SQLString); } /// <summary> /// 執行查詢語句,返回DataSet /// </summary> /// <param name="SQLString">查詢語句</param> /// <returns>DataSet</returns> public DataSet Query(string SQLString) { return dal.Query(SQLString); } /// <summary> /// 執行多條SQL語句,實現數據庫事務。 /// </summary> /// <param name="SQLStringList">SQL語句的哈希表(key為sql語句,value是該語句的SqlParameter[])</param> public void ExecuteSqlTran(Hashtable SQLStringList) { dal.ExecuteSqlTran(SQLStringList); } #endregion 成員方法