|
4 | 4 | using System.Linq.Dynamic.Core.SystemTextJson.Extensions;
|
5 | 5 | using System.Linq.Dynamic.Core.SystemTextJson.Utils;
|
6 | 6 | using System.Linq.Dynamic.Core.Validation;
|
7 |
| -using System.Linq.Expressions; |
8 | 7 | using System.Text.Json;
|
9 | 8 |
|
10 | 9 | namespace System.Linq.Dynamic.Core.SystemTextJson;
|
@@ -676,7 +675,7 @@ public static JsonDocument Select(this JsonDocument source, string selector, par
|
676 | 675 | /// <param name="config">The <see cref="SystemTextJsonParsingConfig"/>.</param>
|
677 | 676 | /// <param name="selector">A projection string expression to apply to each element.</param>
|
678 | 677 | /// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters.</param>
|
679 |
| - /// <returns>An <see cref="JsonElement"/> whose elements are the result of invoking a projection string on each element of source.</returns> |
| 678 | + /// <returns>An <see cref="JsonDocument"/> whose elements are the result of invoking a projection string on each element of source.</returns> |
680 | 679 | public static JsonDocument Select(this JsonDocument source, SystemTextJsonParsingConfig config, string selector, params object?[] args)
|
681 | 680 | {
|
682 | 681 | Check.NotNull(source);
|
@@ -721,6 +720,38 @@ public static JsonDocument Select(this JsonDocument source, Type resultType, str
|
721 | 720 | }
|
722 | 721 | #endregion Select
|
723 | 722 |
|
| 723 | + #region SelectMany |
| 724 | + /// <summary> |
| 725 | + /// Projects each element of a sequence to an <see cref="JsonDocument"/> and combines the resulting sequences into one sequence. |
| 726 | + /// </summary> |
| 727 | + /// <param name="source">The source <see cref="JsonDocument"/></param> |
| 728 | + /// <param name="selector">A projection string expression to apply to each element.</param> |
| 729 | + /// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. </param> |
| 730 | + /// <returns>A <see cref="JsonDocument"/> whose elements are the result of invoking a one-to-many projection function on each element of the input sequence.</returns> |
| 731 | + public static JsonDocument SelectMany(this JsonDocument source, string selector, params object?[] args) |
| 732 | + { |
| 733 | + return SelectMany(source, SystemTextJsonParsingConfig.Default, selector, args); |
| 734 | + } |
| 735 | + |
| 736 | + /// <summary> |
| 737 | + /// Projects each element of a sequence to an <see cref="JsonDocument"/> and combines the resulting sequences into one sequence. |
| 738 | + /// </summary> |
| 739 | + /// <param name="source">The source <see cref="JsonDocument"/></param> |
| 740 | + /// <param name="config">The <see cref="SystemTextJsonParsingConfig"/>.</param> |
| 741 | + /// <param name="selector">A projection string expression to apply to each element.</param> |
| 742 | + /// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters.</param> |
| 743 | + /// <returns>A <see cref="JsonDocument"/> whose elements are the result of invoking a one-to-many projection function on each element of the input sequence.</returns> |
| 744 | + public static JsonDocument SelectMany(this JsonDocument source, SystemTextJsonParsingConfig config, string selector, params object?[] args) |
| 745 | + { |
| 746 | + Check.NotNull(source); |
| 747 | + Check.NotNull(config); |
| 748 | + Check.NotNullOrEmpty(selector); |
| 749 | + |
| 750 | + var queryable = ToQueryable(source, config); |
| 751 | + return ToJsonDocumentArray(() => queryable.SelectMany(config, selector, args)); |
| 752 | + } |
| 753 | + #endregion SelectMany |
| 754 | + |
724 | 755 | #region Single
|
725 | 756 | /// <summary>
|
726 | 757 | /// Returns the only element of a sequence, and throws an exception if there
|
|
0 commit comments