public static List <T> GetAll <T>(string connection_string, string p_EmpID) where T : IEntity, new() { // IEntity entity = new T(); EntityAttribute attr = GetEntityAttribute(typeof(T)); string sp_Name = "usp_GetMenuByEmpID"; System.Data.SqlClient.SqlParameter[] p_SP = new System.Data.SqlClient.SqlParameter[1]; p_SP[0] = new System.Data.SqlClient.SqlParameter(); p_SP[0].Direction = ParameterDirection.Input; p_SP[0].ParameterName = "@empID"; p_SP[0].SqlDbType = SqlDbType.NVarChar; p_SP[0].Value = p_EmpID; DataTable data = SqlHelper.ExecuteDataTable(connection_string, CommandType.StoredProcedure, sp_Name, p_SP); return((attr.EntityHelper as EntityHelper <T>).DataTable2List(data)); }
public static int DeleteTable <T>(string connection_string, ColumnFilterList filter_list) where T : IEntity, new() { EntityAttribute attr = GetEntityAttribute(typeof(T)); StringBuilder sb = new StringBuilder(100); ParameterBuilder paramlist = new ParameterBuilder(filter_list.Count); sb.Append(" delete from ["); sb.Append(attr.TableName); sb.Append("] "); for (int i = 0; i < filter_list.Count; i++) { sb.Append(i > 0 ? " and " : " where "); string param_name = string.Format("@__{0}__", filter_list[i].Name); sb.AppendFormat(" [{0}] = {1} ", filter_list[i].Name, param_name); paramlist.Add(param_name, filter_list[i].Value); } // return GetListBySql<T>(transaction, sb.ToString(), paramlist.ToArray()); return(ExecuteNonQuery(connection_string, CommandType.Text, sb.ToString(), paramlist.ToArray())); }