소스 검색

Merge branch 'kenric' into issues

Kenric Nugteren 6 달 전
부모
커밋
c9a3186ef2

+ 5 - 1
InABox.Core/CoreUtils.cs

@@ -2021,7 +2021,11 @@ namespace InABox.Core
         }
         public static Expression DeserialiseExpression(this CoreBinaryReader reader, Type t)
         {
-            var expressionType = (SerialisedExpressionType)reader.ReadByte();
+            return DeserialiseExpression(reader, t, reader.ReadByte());
+        }
+        public static Expression DeserialiseExpression(this CoreBinaryReader reader, Type t, byte type)
+        {
+            var expressionType = (SerialisedExpressionType)type;
             switch (expressionType)
             {
                 case SerialisedExpressionType.Member:

+ 23 - 3
InABox.Core/Query/Filter.cs

@@ -1523,9 +1523,24 @@ namespace InABox.Core
         public void DeserializeBinary(CoreBinaryReader reader)
         {
             // For compatability purposes when redesigning system to no longer use Serializable Expression.
-            reader.ReadByte();
-
-            Property = reader.ReadString();
+            var b = reader.ReadByte();
+            if(b != 0)
+            {
+                var exp = reader.DeserialiseExpression(typeof(T), b);
+                if(exp is ParameterExpression)
+                {
+                    Property = "";
+                }
+                else
+                {
+                    Property = CoreUtils.ExpressionToString(typeof(object), exp);
+                    Logger.Send(LogType.Information, "", $"Non-zero byte: {Property} ({exp.Type})");
+                }
+            }
+            else
+            {
+                Property = reader.ReadString();
+            }
 
             Operator = (Operator)reader.ReadByte();
             if(Operator == Operator.Not)
@@ -2039,6 +2054,11 @@ namespace InABox.Core
             var result = (Activator.CreateInstance(finaltype) as IFilter)!;
 
             var prop = data["Expression"].ToString();
+            if (prop.StartsWith('{'))
+            {
+                var exp = CoreUtils.StringToExpression(prop);
+                prop = CoreUtils.ExpressionToString(typeof(object), exp);
+            }
             var op = (Operator)int.Parse(data["Operator"].ToString());
 
             if(data.TryGetValue("IsNot", out var isNotValue) && isNotValue is bool b)

+ 1 - 1
inabox.database.sqlite/SQLiteProvider.cs

@@ -1825,7 +1825,7 @@ public class SQLiteProvider : IProvider
     private string GetFilterClauseNonGeneric(Type T, SQLiteCommand command, char prefix, IFilter? filter, List<Tuple<string, string, string, string>> tables,
         Dictionary<string, string> fieldmap, List<string> columns, bool useparams)
     {
-        if (filter == null || filter.Property.IsNullOrWhiteSpace())
+        if (filter == null)
             return "";
 
         var result = "";

+ 1 - 1
inabox.wpf/DynamicGrid/Editors/FilterEditor/Nodes/PropertyNode.cs

@@ -52,7 +52,7 @@ public class PropertyNode<T> : Button
             .ToList();
         properties.Sort();
         ColumnNames = properties.ToArray();
-        SelectedProperty = property;
+        SelectedProperty = properties.Contains(property) ? property : null;
 
         Click += PropertyNode_Click;
     }