-
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with Query over JObject, Filter with SubProperty not returning the correct value #415
Comments
Hello @luizfbicalho , It's possible that var retorno = dados.AsQueryable()
.Select("new ( string(Id) as Id, string(Descricao) as Descricao,new ( string(Tipo.Id) as Id) as Tipo, string(TipoId) as TipoId, string(Custo) as Custo)"); Once we change it, it now filters the Tipo.Id as you initially wanted. Best Regards, Jon Performance Libraries Runtime Evaluation |
Thanks @JonathanMagnan , I'll try that. |
One thing before closing this
Shoudn't it work inspecting the JObject? "Target object is not an ExpandoObject" |
Unfortunately, the library is not 100% compatible with So the answer is no for the moment. We might want to improve the code later to try to support more but there is no plan for now. |
I didn't look deeply inside of the code, but is there some kind of translator that I could implement, for example I'm not sure if I was clear about it |
I'm not exactly sure but this answer might help you: #410 (comment) This is possible for you to add some method that will be recognized by the library |
I was thinking about something more transparent, I mean something like this IReader{GetProperties(T obj).......} and in Where("t=>t.Property==@0",X) would use the DI or some array of readers kind of the way newtonsoft.json has the converters. I imagine that this is a huge change in the way that this works today, if so, I'm just pointing some ideas to help in the future |
I was more thinking in this direction: Use it: var array = JArray.Parse(@"[
{
""first"": 1,
""City"": ""Paris"",
""third"": ""test""
},
{
""first"": 2,
""City"": ""New York"",
""third"": ""abc""
}]");
var results = array.Where("City == @0", "Paris").ToDynamicArray();
foreach (var result in results)
{
Console.WriteLine(result.first);
} Logic public static JArray Where(this JArray source, JsonParsingConfig config, string predicate, params object?[] args)
{
Check.NotNull(source);
var array = new JArray();
if (source.Count == 0)
{
return array;
}
// Convert the JArray to a dynamic object array / queryable.
var enumerable = source.ToDynamicJsonClassArray(config.DynamicJsonClassOptions).AsQueryable();
// Apply the where clause.
var results = enumerable.Where(config, predicate, args);
// Convert the dynamic results back to a JArray.
foreach (var result in results)
{
array.Add(JObject.FromObject(result));
}
return array;
} |
Will be solved by #789 |
I created this console application to reproduce my problem
If you look at the results , the count should be the same, but for some reason, retorno2 is filtering for the Root Id of the object, and not the Tipo property and Id SubProperty
The text was updated successfully, but these errors were encountered: