public List <T> GetAllByUserId(string spname, string Activity, string id) { List <T> objlist = new List <T>(); Connection objCon = new Connection(); SqlConnection con = objCon.GetConnection(); if (con.State == ConnectionState.Open) { con.Close(); } else { con.Open(); } SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = 200000; cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = spname; cmd.Parameters.AddWithValue("@id", id); if (!string.IsNullOrEmpty(Activity)) { cmd.Parameters.AddWithValue("@Activity", Activity); } SqlDataAdapter adp = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adp.Fill(dt); objlist = Encrypt.ConvertDataTableToList <T>(dt); con.Close(); return(objlist); }
public List <T> GetAll(string spname, string Activity) { List <T> objlist = new List <T>(); Connection objCon = new Connection(); SqlConnection con = objCon.GetConnection(); if (con.State == ConnectionState.Open) { con.Close(); } else { con.Open(); } var list = new List <T>(); //using (IDbConnection db = objCon.GetConnection()) //{ // var queryParameters = new DynamicParameters(); // if (!string.IsNullOrEmpty(Activity)) // queryParameters.Add("@Activity", Activity); // list = db.Query<T>(spname, queryParameters,null,false,999999999,CommandType.StoredProcedure).ToList(); //} SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = 200000; cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = spname; if (!string.IsNullOrEmpty(Activity)) { cmd.Parameters.AddWithValue("@Activity", Activity); } SqlDataAdapter adp = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adp.Fill(dt); objlist = Encrypt.ConvertDataTableToList <T>(dt); con.Close(); return(objlist); }