Parcourir la source

String Summary Fields are now DISTINCT
Added DataType to IDynamicDataGrid interface

frogsoftware il y a 11 heures
Parent
commit
26369726f4

+ 11 - 7
inabox.database.sqlite/SQLiteProvider.cs

@@ -2024,12 +2024,12 @@ public class SQLiteProvider : IProvider
     {
         return calculation switch
         {
-            AggregateCalculation.Sum => TResult == typeof(decimal) ? "DECIMAL_SUM" : "SUM",
-            AggregateCalculation.Count => "COUNT",
-            AggregateCalculation.Maximum => "MAX",
-            AggregateCalculation.Minimum => "MIN",
-            AggregateCalculation.Average => "AVERAGE",
-            AggregateCalculation.Concat => "GROUP_CONCAT",
+            AggregateCalculation.Sum => TResult == typeof(decimal) ? "DECIMAL_SUM({0})" : "SUM({0})",
+            AggregateCalculation.Count => "COUNT({0})",
+            AggregateCalculation.Maximum => "MAX({0})",
+            AggregateCalculation.Minimum => "MIN({0})",
+            AggregateCalculation.Average => "AVERAGE({0})",
+            AggregateCalculation.Concat => "GROUP_CONCAT(DISTINCT {0})",
             _ => throw new Exception(string.Format("{0}.{1} is not a valid aggregate", columnname, calculation)),
         };
     }
@@ -2742,7 +2742,11 @@ public class SQLiteProvider : IProvider
             if (fieldmap.TryGetValue(column.Name, out string? value))
             {
                 if (aggregates != null && aggregates.TryGetValue(column.Name, out var aggregateFnc))
-                    combined[constants != null ? column.Name : String.Format("{0:D8}", combined.Keys.Count)] = string.Format("{0}({1}) as [{2}]", aggregateFnc, value, column.Name);
+                {
+                    var _col = string.Format(aggregateFnc, value);
+                    combined[constants != null ? column.Name : String.Format("{0:D8}", combined.Keys.Count)] =
+                        string.Format("{0} as [{1}]", _col, column.Name);
+                }
                 else
                     combined[constants != null ? column.Name : String.Format("{0:D8}", combined.Keys.Count)] = string.Format("{0} as [{1}]", value, column);
             }

+ 4 - 0
inabox.wpf/DynamicGrid/DynamicDataGrid.cs

@@ -27,6 +27,8 @@ public interface IDynamicDataGrid : IDynamicGrid
     string? ColumnsTag { get; set; }
 
     IColumns LoadEditorColumns();
+    
+    Type DataType { get; }
 }
 
 public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid where TEntity : Entity, IRemotable, IPersistent, new()
@@ -42,6 +44,8 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
 
     private Column<TEntity>[] FilterColumns;
 
+    public Type DataType => typeof(TEntity);
+
     public DynamicDataGrid() : base()
     {
         var fields = DatabaseSchema.Properties(typeof(TEntity));