Skip to content

Suggestion: IAsyncQueryable #77698

@tarekgh

Description

@tarekgh

[jcouv summary:] requesting support for await in expression trees.


@lillo42 commented on Wed Dec 19 2018

I'm studying C# 8 and new we have a new interface call IAsyncEnumerable and I was think maybe it's a good ideia create a new interface call IAsyncQueryable to be possible using await foreach async with ORM like EF or NHibernarte:

IAsyncQueryable query = database.Where(...);

await foreach(var a in query) {
...
}

I was thinking IAsyncQueryable could be:

public interface IAsyncQueryable : IAsyncEnumerable
{
   Type ElementType { get; }
    Expression Expression { get; }
    IQueryProvider Provider { get; }
}


public interface IAsyncQueryable<T> : IAsyncQueryable, IAsyncEnumerable<T>
{

}

or

public interface IAsyncQueryable : IQueryable, IAsyncEnumerable
{

}


public interface IAsyncQueryable<T> : IQueryable<T>, IAsyncQueryable,  IAsyncEnumerable<T>
{

}

@Suchiman commented on Wed Dec 19 2018

Since IQueryable is about composing a query rather than constructing an execution pipeline, it would probably make more sense to follow the current Approach (used by EF) of adding an extension like this

public static IAsyncEnumerable<TSource> AsAsyncEnumerable<TSource>(this IQueryable<TSource> source)

@quinmars commented on Thu Dec 20 2018

The async enumerable implementation is developed in the dotnet/reactive repo. And there actually is already an IAsyncQueryable interface:

https://github.com/dotnet/reactive/blob/IxAsyncCSharp8/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs


@tarekgh commented on Thu Jan 17 2019

cc @stephentoub


@stephentoub commented on Thu Jan 17 2019

Without language support for awaits in expression trees, I don't think there's much that can or should be done here.
cc: @cston, @jaredpar


@jaredpar commented on Thu Jan 17 2019

I agree. There is currently no plans to invest in our expression tree support at this time.


@tarekgh commented on Thu Jan 17 2019

@jaredpar should we move this issue to your repo you may track it for the future if anything change?


@jaredpar commented on Thu Jan 17 2019

Either way. This is one of those features that crosses our repositories so I'm fine with it being here or there.


@tarekgh commented on Thu Jan 17 2019

Thanks @jaredpar I'll move it because corefx can support it if the it is decided from your side to support it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions