aboutsummaryrefslogtreecommitdiff
path: root/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/OrderByClause.cs
diff options
context:
space:
mode:
Diffstat (limited to 'dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/OrderByClause.cs')
-rw-r--r--dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/OrderByClause.cs50
1 files changed, 0 insertions, 50 deletions
diff --git a/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/OrderByClause.cs b/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/OrderByClause.cs
deleted file mode 100644
index 734d044..0000000
--- a/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/OrderByClause.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-namespace CrupestApi.Commons.Crud;
-
-public class OrderByItem
-{
- public OrderByItem(string columnName, bool isAscending)
- {
- ColumnName = columnName;
- IsAscending = isAscending;
- }
-
- public string ColumnName { get; }
- public bool IsAscending { get; }
-
- public string GenerateSql()
- {
- return $"{ColumnName} {(IsAscending ? "ASC" : "DESC")}";
- }
-}
-
-public interface IOrderByClause : IClause
-{
- List<OrderByItem> Items { get; }
- // Contains "ORDER BY" keyword!
- string GenerateSql(string? dbProviderId = null);
-}
-
-public class OrderByClause : IOrderByClause
-{
- public List<OrderByItem> Items { get; } = new List<OrderByItem>();
-
- public OrderByClause(params OrderByItem[] items)
- {
- Items.AddRange(items);
- }
-
- public static OrderByClause Create(params OrderByItem[] items)
- {
- return new OrderByClause(items);
- }
-
- public List<string> GetRelatedColumns()
- {
- return Items.Select(x => x.ColumnName).ToList();
- }
-
- public string GenerateSql(string? dbProviderId = null)
- {
- return "ORDER BY " + string.Join(", ", Items.Select(i => i.GenerateSql()));
- }
-}