In connection with the foregoing, this is the place where I landed when I had the same error. But in my case, I wanted to set the Combine Option to No Tracking . I came across this when I had an excel export method that tried to disable IQueryable object tracking. Going through a lot of data that I was not going to change, I do not need to track changes.
A line of code like the one below would fail if you tried to apply some IQueryables to the ObjectQuery class (but succeed on others.)
var y = ((ObjectQuery)query).MergeOption = MergeOption.NoTracking;
Instead, I replaced it with AsNoTracking
query = query.AsNoTracking();
Relating to the original question, this would potentially be similar to the following: the extension method in DBQuery added to System.Data.Entity
List<Transactions> transactions = DefaultContext.Transactions.AsNoTracking().ToList();
Prefabricated article: https://msdn.microsoft.com/en-us/library/hh949853(v=vs.113).aspx
source share