Compare commits

...

2 Commits

Author SHA1 Message Date
Simple_Not
e445c2bda1 post list
Some checks failed
continuous-integration/drone/push Build is failing
2022-10-20 11:38:52 +10:00
Simple_Not
f5349db697 post list 2022-10-20 11:35:59 +10:00

View File

@ -14,8 +14,9 @@ namespace NeDvachAPI
public static Post[] DbList()
{
// Build connection string using parameters from portal
Post[] posts = new Post[10];
int postCount = 0;
//Post[] posts = new Post[10];
List<Post> posts = new List<Post>();
//int postCount = 0;
string received = "";
string connString =
String.Format(
@ -33,13 +34,22 @@ namespace NeDvachAPI
conn.Open();
using (var command = new NpgsqlCommand(@"
// using ( var command = new NpgsqlCommand(@"
// SELECT * FROM
// (SELECT post_id, substring(post,1,200)
// FROM dvach
// ORDER BY post_id DESC
// limit 10
// )
subquery ORDER BY post_id ASC", conn) )
using ( var command = new NpgsqlCommand(@"
SELECT * FROM
(SELECT post_id, substring(post,1,200)
FROM dvach
ORDER BY post_id
DESC limit 10)
subquery ORDER BY post_id ASC", conn))
(
SELECT post_id, post
FROM dvach
ORDER BY post_id DESC
) subquery
ORDER BY post_id ASC", conn) )
{
var reader = command.ExecuteReader();
@ -58,8 +68,9 @@ namespace NeDvachAPI
Id = reader.GetInt32(0),
Text = reader.GetString(1)
};
posts[postCount] = receivedPost;
postCount++;
posts.Add(receivedPost);
//posts[postCount] = receivedPost;
//postCount++;
}
reader.Close();
}