// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq.Expressions;
namespace System.Linq
{
///
/// Provides a set of extension methods for asynchronous enumerable sequences represented using expression trees.
///
public static partial class AsyncQueryable
{
///
/// Converts the specified asynchronous enumerable sequence to an expression representation.
///
/// The type of the elements in the sequence.
/// The asynchronous enumerable sequence to represent using an expression tree.
/// An asynchronous enumerable sequence using an expression tree to represent the specified asynchronous enumerable sequence.
public static IAsyncQueryable AsAsyncQueryable(this IAsyncEnumerable source)
{
if (source == null)
throw new ArgumentNullException("source");
var queryable = source as IAsyncQueryable;
if (queryable != null)
{
return queryable;
}
return new AsyncEnumerableQuery(source);
}
private static Expression GetSourceExpression(IAsyncEnumerable source)
{
var queryable = source as IAsyncQueryable;
if (queryable != null)
{
return queryable.Expression;
}
return Expression.Constant(source, typeof(IAsyncEnumerable));
}
}
}