public static List <T> Select(List <ParamValue> paramValues, string table = null) { System.Data.DataTable dataTable; try { if (string.IsNullOrEmpty(table)) { table = (typeof(T)).BaseType.Name == "Object" ? typeof(T).Name : (typeof(T)).BaseType.Name; } using (var connection = DBHelper.Connection()) { var whereSucces = paramValues.FirstOrDefault(p => p.Where != null && p.Where.Count != 0); var likeSucces = paramValues.FirstOrDefault(p => p.Like != null && p.Like.Count != 0); var sql = SqlOperatorler.SqlWhere(paramValues, table, whereSucces); var firstOrDefault = paramValues.FirstOrDefault(p => !string.IsNullOrEmpty(p.Between) && p.Where != null && p.Where.Count > 0); sql = SqlOperatorler.SqlAnd(firstOrDefault, sql); sql = SqlOperatorler.SqlBetween(paramValues, sql); sql = SqlOperatorler.SqlOrderByAsc(paramValues, sql); sql = SqlOperatorler.SqlLike(paramValues, likeSucces, whereSucces, sql); sql = SqlOperatorler.SqlOrderByDesc(paramValues, sql); sql = SqlOperatorler.SqlPagging(paramValues, sql); dataTable = DataTableProses.DataTableFill(paramValues, sql, connection); connection.Close(); } } catch (Exception ex) { throw new Exception(ex.Message); } var anonimT = DataTableConvert.DataTableToList <T>(dataTable); return(anonimT); }
public static int Count(List <ParamValue> paramValues, string table) { System.Data.DataTable dataTable; try { using (var connection = DBHelper.Connection()) { var whereSucces = paramValues.FirstOrDefault(p => p.Where != null && p.Where.Count != 0); var likeSucces = paramValues.FirstOrDefault(p => p.Like != null && p.Like.Count != 0); var sql = SqlOperatorler.SqlWhereCount <T>(paramValues, table, whereSucces); var firstOrDefault = paramValues.FirstOrDefault(p => !string.IsNullOrEmpty(p.Between) && p.Where != null && p.Where.Count > 0); sql = SqlOperatorler.SqlAnd(firstOrDefault, sql); sql = SqlOperatorler.SqlBetween(paramValues, sql); sql = SqlOperatorler.SqlOrderByAsc(paramValues, sql); sql = SqlOperatorler.SqlLike(paramValues, likeSucces, whereSucces, sql); sql = SqlOperatorler.SqlOrderByDesc(paramValues, sql); dataTable = DataTableProses.DataTableFill(paramValues, sql, connection); connection.Close(); } } catch (Exception ex) { Logger.Log(ex.Message, true, true); throw new Exception(ex.Message); } return(Convert.ToInt32(dataTable.Rows[0]["Deger"])); }