Skip to content

Commit

Permalink
Select
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Apr 8, 2024
1 parent 7f4f273 commit 5ea2d44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src-console/ConsoleApp_net6.0/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ static void Main(string[] args)
""third"": ""abc""
}]");

var results = array.Where("City == @0", "Paris").ToDynamicArray();
foreach (var result in results)
var where = array.Where("City == @0", "Paris");
foreach (var result in where)
{
Console.WriteLine(result.first);
Console.WriteLine(result["first"]);
}

var select = array.Select("City");
foreach (var result in select)
{
Console.WriteLine(result);
}

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ public static JArray Where(this JArray source, JsonParsingConfig config, string
private static JArray ToJArray(Func<IQueryable> func)
{
var array = new JArray();
foreach (var element in func())
foreach (var dynamicElement in func())
{
array.Add(JObject.FromObject(element));
var element = dynamicElement is DynamicClass dynamicClass ? JObject.FromObject(dynamicClass) : dynamicElement;
array.Add(element);
}
return array;
}
Expand Down

0 comments on commit 5ea2d44

Please sign in to comment.