LinqKit has an extension method ForEach for IEnumerable which clashes with System.Collections.Generic.IEnumerable.
Error 4 The call is ambiguous between the following methods or properties:
'LinqKit.Extensions.ForEach<Domain>(System.Collections.Generic.IEnumerable<Domain>, System.Action<Domain>)'
and
'System.Linq.EnumerableExtensionMethods.ForEach<Domain>(System.Collections.Generic.IEnumerable<Domain>, System.Action<Domain>)'
How can I get rid of this error?
Enumerable, in the framework, does not declare an extension forForEach(). Both of these are from external references.You should consider only using one of them – either the reference that’s adding
EnumerableExtensionMethodsor theLinqKit.(This, btw, is one reason that using the same namespace as the framework causes problems – in this case, the author of
EnumerableExtensionMethodsplaced it inSystem.Linq, which is going to cause an issue any time you’re using Linq and you have a namespace clash.)If you truly need to use this method, then you’ll have to call it directly instead of using the extension method, ie:
Or:
That being said, I would personally just use a foreach loop to process the elements.