Ambiguous method call between extension methods

I downloaded the DynamicLinq library through the nuget package. I used it as below

db.ReservationSet.Where("blbalbabla",1,2) 

But I get below exceptions.

Error 38 The call is ambiguous between the following methods or properties: "System.Linq.Dynamic.DynamicQueryable.Where (System.Linq.IQueryable, string, params object []) 'and" System.Linq.Dynamic.DynamicQueryable.Where (System.Linq .IQueryable, string, params object []) 'F: \ Projects \ IEKeysNew \ IEKEYS \ Controllers \ ReportController.cs 145 22 IEKEYS

Here is a sign of both methods.

 public static IQueryable<T> Where<T>(this IQueryable<T> source, string predicate, params object[] values); public static IQueryable Where(this IQueryable source, string predicate, params object[] values); 

I could not find something to get rid of this compile-time exception.

+6
source share
4 answers

Unfortunately, another third-party DLL contains the same linq internaly dynamic library. The Trirand jQGrid library contains the dynamic linq library, and this is causing a conflict when importing the System.Linq.Dynamic library.

+6
source

Remove the following from your code:

 using System.Linq; 
0
source

What type is db.ReservationSet ?

If this is a collection of instances of your MyClass , try writing db.ReservationSet.Where<MyClass>("blbalbabla",1,2) .

If it is assigned to IQueryable , try writing:
((IQueryable )db.ReservationSet).Where("blbalbabla",1,2)

0
source

I know that this is not the most beautiful way. But I have no other idea.

Divide your class into 2 cs files and create partial classes. Therefore, you will remove the use of System.Linq from one of the documents. Try it, maybe it will work.

0
source

Source: https://habr.com/ru/post/921199/


All Articles