-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The call is ambiguous between the following methods or properties (IAsyncEnumerable, IQueryable) #18220
Comments
So the problem is that there is lot's of conflict between This simply makes it impossible to use both in the same file without massive headache or using unreadable static methods... |
And if you remove |
The workaround is to put extensions methods at the root of your project. public static IAsyncEnumerable<TEntity> AsAsyncEnumerable<TEntity>(this Microsoft.EntityFrameworkCore.DbSet<TEntity> obj) where TEntity : class
{
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AsAsyncEnumerable(obj);
}
public static IQueryable<TEntity> Where<TEntity>(this Microsoft.EntityFrameworkCore.DbSet<TEntity> obj, System.Linq.Expressions.Expression<Func<TEntity, bool>> predicate) where TEntity : class
{
return System.Linq.Queryable.Where(obj, predicate);
} It solves conflicts because it seems the compiler prefer the extension method inside the current namespace before the usings one... this is shitty situation though. |
@NicolasDorier - If your intention to use EF method can just call |
Closing as same root cause as #18124 |
Afer adding this, I receive the following error: Expression of type 'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable This doesn't work:
This does:
Is there any other way vs. adding AsQuerable() to thousands of queries? |
I can maybe suggest the answer cited here, it helped me with a similar problem |
@nafberger and others, note that this problem has been fixed for EF Core 6.0 (#24041), the latest previous should already not trigger the ambiguity. |
In .NET Core 3.0, my code which worked in 2.1 does not compile anymore:
This is the case of a simple
dbset.Where
My usings:
If I remove
System.Linq
, then it does not findWhere
.The text was updated successfully, but these errors were encountered: