Skip to content

Commit 6cbc452

Browse files
2881028810
authored andcommitted
- 修复 WhereDynamicFilter System.Text.Json 下的问题;
1 parent d0c5d84 commit 6cbc452

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

Examples/base_entity/Program.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ static void Main(string[] args)
175175
""Operator"" : ""eq"",
176176
""Value"" : ""product-4""
177177
},
178+
{
179+
""Field"" : ""testint"",
180+
""Operator"" : ""Range"",
181+
""Value"" : [100,200]
182+
},
183+
{
184+
""Field"" : ""testint"",
185+
""Operator"" : ""Range"",
186+
""Value"" : [""101"",""202""]
187+
},
178188
]
179189
}
180190
");
@@ -228,14 +238,23 @@ static void Main(string[] args)
228238
""Field"" : ""testint"",
229239
""Operator"" : 8,
230240
""Value"" : ""12""
241+
},
242+
{
243+
""Field"" : ""testint"",
244+
""Operator"" : ""Range"",
245+
""Value"" : [100,200]
246+
},
247+
{
248+
""Field"" : ""testint"",
249+
""Operator"" : ""Range"",
250+
""Value"" : [""101"",""202""]
231251
}
232252
]
233253
}
234254
", config);
235255
Products.Select.WhereDynamicFilter(wdy1).ToList();
236256
Products.Select.WhereDynamicFilter(wdy2).ToList();
237257

238-
239258
var items1 = Products.Select.Limit(10).OrderByDescending(a => a.CreateTime).ToList();
240259
var items2 = fsql.Select<Products>().Limit(10).OrderByDescending(a => a.CreateTime).ToList();
241260

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,20 @@ string[] getFiListValue()
551551
fiValueList.Add(string.Concat(fiValueIeItem));
552552
return fiValueList.ToArray();
553553
}
554+
var fiValueType = fi.Value.GetType();
555+
if (fiValueType.FullName == "System.Text.Json.JsonElement")
556+
{
557+
var fiValueKind = fiValueType.GetProperty("ValueKind").GetValue(fi.Value, null).ToString();
558+
if (fiValueKind == "Array")
559+
{
560+
fiValueIe = fiValueType.GetMethod("EnumerateArray", new Type[0])?.Invoke(fi.Value, null) as IEnumerable;
561+
var fiValueList = new List<string>();
562+
foreach (var fiValueIeItem in fiValueIe)
563+
fiValueList.Add(string.Concat(fiValueIeItem));
564+
return fiValueList.ToArray();
565+
}
566+
return fi.Value.ToString().Split(',');
567+
}
554568
return new string[0];
555569
}
556570

0 commit comments

Comments
 (0)