Ambiguous call when using LINQ extension method and ef core
Hello, I have a problem on ambiguous reference between EF Core and System.Linq because projects reference System.Linq.Async. When I clone the repo, and delete this reference, add local reference to the dll, there is no problem. Could you generate a release without this ? Or have you a solution ?
A workaround to disambiguate the two extensions methods ToListAsync is to cast your DbSet<T> to an IQueryable<T>, since only the EF Core version of ToListAsync works on these.
using FluentFTP;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace ConsoleApp37
{
class MySet : DbSet<object>
{
}
class Program
{
static void Main(string[] args)
{
new FtpClient().GetListingAsyncEnumerable().ToListAsync();
((IQueryable<object>)new MySet()).ToListAsync();
}
}
}
From a class design perspective you would maybe want to separate the responsibilities of interacting with an FTP and a database into two separate classes.
@jnyrup Thanks for helping!
@bastienchauvin You want me to delete the ref to System.Linq.Async for which platform(s)? And are you having issues with ToListAsync as Jonas mentioned?
After update from 33.0 to 3.1 I get many errors in my project when calling where clauses on db context like this:
The call does not clearly distinguish between the following methods or properties:
"System.Linq.Queryable.Where
here is an example call with ambiguities in the where clause
var filialArtikelDaten = await _ctx.FilialArtikeldaten
.Where(fa => fa.ArtikelId == Guid.Empty)
.ToListAsync(cancellationToken)
.ConfigureAwait(false);
Then it's a new issue and I'll look into it.
On Fri, Apr 9, 2021, 6:49 PM JanLorenz77 @.***> wrote:
After update from 33.0 to 3.1 I get many errors in my project when calling where clauses on db context like this:
The call does not clearly distinguish between the following methods or properties: "System.Linq.Queryable.Where (System.Linq.IQueryable , System.Linq.Expressions.Expression <System.Func <TSource, bool >>)" and "System.Linq.AsyncEnumerable.Where (System.Collections.Generic.IAsyncEnumerable , System.Func <TSource, bool>)"
here is an example call with ambiguities in the where clause var filialArtikelDaten = await _ctx.FilialArtikeldaten .Where(fa => fa.ArtikelId == Guid.Empty) .ToListAsync(cancellationToken) .ConfigureAwait(false);
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/robinrodricks/FluentFTP/issues/703#issuecomment-816676070, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT3UKSDSDPEF22F2N3DSWDTH35FFANCNFSM42PRTNNA .
Then it's a new issue and I'll look into it.
Existing Linq queries will no longer work after the update to 33.1.x. This has to do with the addition of System.Linq.Async. Can this additional package be removed?
@nbakx-vbe @JanLorenz77 @jnyrup Done. Please check:
https://www.nuget.org/packages/FluentFTP/33.1.7
Yes this solves all the LINQ errors
Great!