瀏覽代碼

Fix to bug with lookup formatter being passed the wrong type

Kenric Nugteren 9 月之前
父節點
當前提交
6ec96a7243
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 1 1
      InABox.Core/Editors/Utils/DataLookupEditor.cs
  2. 3 3
      InABox.Core/ILookupDefinition.cs

+ 1 - 1
InABox.Core/Editors/Utils/DataLookupEditor.cs

@@ -51,7 +51,7 @@ namespace InABox.Core
             result.Columns.Add(new CoreColumn { ColumnName = "Display", DataType = typeof(string) });
             foreach (var row in result.Rows)
             {
-                row["Display"] = LookupFactory.FormatLookup(Type, row, columnname);
+                row["Display"] = LookupFactory.FormatLookup(parent, Type, row, columnname);
             }
 
             return result;

+ 3 - 3
InABox.Core/ILookupDefinition.cs

@@ -438,7 +438,7 @@ namespace InABox.Core
             return DefaultFormatLookup(values, exclude);
         }
 
-        public static string FormatLookup(Type TEntity, CoreRow row, string column)
+        public static string FormatLookup(Type TEntity, Type TLookup, CoreRow row, string column)
         {
             var generator = GetLookupGenerator(TEntity, column);
             if(generator != null)
@@ -447,7 +447,7 @@ namespace InABox.Core
             }
             else
             {
-                return FormatLookup(TEntity, row.ToDictionary(new[] { "Display" }), Array.Empty<string>());
+                return FormatLookup(TLookup, row.ToDictionary(new[] { "Display" }), Array.Empty<string>());
             }
         }
 
@@ -504,7 +504,7 @@ namespace InABox.Core
 
         public static string FormatLookup<TEntity, TLookup, TLookupLink>(CoreRow row, Expression<Func<TEntity, TLookupLink>> column)
             where TLookupLink : IEntityLink<TLookup>
-            => FormatLookup(typeof(TEntity), row, CoreUtils.GetFullPropertyName(column, "."));
+            => FormatLookup(typeof(TEntity), typeof(TLookup), row, CoreUtils.GetFullPropertyName(column, "."));
 
         public static void OnCreateItem<TEntity, TLookup, TLookupLink>(Expression<Func<TEntity, TLookupLink>> column, TEntity[] items, TLookup item)
             where TLookupLink : IEntityLink<TLookup>