How can I get the parameters of an Entity Framework query?
If I create a query of IQueryable<T> , I can call .ToString() to get the SQL that will be called, but that SQL may contain parameters like @p__linq__0, @p__linq__1, etc. Is there a way to get those parameters and their values from the IQueryable<T> It's frustratingly complicated, in my experience, but this code got me there: var dbQuery = (DbQuery<T>)query; // get the IInternalQuery internal variable from the DbQuery object var iqProp = dbQuery.GetType().GetProperty("InternalQuery", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); var iq = iqProp.GetValue(dbQuery, null);