AsyncQueryableEx.cs 927 B

1234567891011121314151617181920212223242526
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. using System.Linq.Expressions;
  6. namespace System.Linq
  7. {
  8. /// <summary>
  9. /// Provides a set of extension methods for asynchronous enumerable sequences represented using expression trees.
  10. /// </summary>
  11. [LocalQueryMethodImplementationType(typeof(AsyncEnumerableEx))]
  12. public static partial class AsyncQueryableEx
  13. {
  14. private static Expression GetSourceExpression<TSource>(IAsyncEnumerable<TSource> source)
  15. {
  16. if (source is IAsyncQueryable<TSource> queryable)
  17. {
  18. return queryable.Expression;
  19. }
  20. return Expression.Constant(source, typeof(IAsyncEnumerable<TSource>));
  21. }
  22. }
  23. }