I have a Employees DbSet in my Entity Framework context that can be queried as:
IQueryable employees = _context.Employees;
The Idea is to execute the below method using Reflection:
var result= _context.Employees.FirstOrDefault()
I want to query the context for FirstOrDefault using REFLECTION.
var firstordefault = typeof(Queryable).GetMethod("FirstOrDefault", BindingFlags.Static | BindingFlags.Public);
When I execute the above code, it gives me the error:
Ambiguous match found
System.Reflection.AmbiguousMatchException was unhandled by user code
HResult=-2147475171 Message=Ambiguous match found. Source=mscorlib StackTrace: at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) at System.Type.GetMethod(String name, BindingFlags bindingAttr) at Tests.test_dynamic.TestMethod2() in e:\Projects\Tests\test_dynamic.cs:line 70 InnerException:
How can I resolve the ambiguity of this method.