public List <Post> GetWhereSortBy(string w, string o = null) { list.Clear(); List <int> ids = new List <int>(); if (o == null) { using (IDataReader result = connection.select("*").from("post").where (w).Execute()) { while (result.Read()) { ids.Add((int)result["id"]); } } } else { using (IDataReader result = connection.select("*").from("post").where (w).orderby(o).Execute()) { while (result.Read()) { ids.Add((int)result["id"]); } } } foreach (int id in ids) { Post post = new Post(this.connection); post.id = id; post.Load(); list.Add(post); } return(list); }