My C# VS2015 application throws this exception:
System.InvalidCastException was unhandled
Message=Unable to cast object of type 'System.Data.Entity.Infrastructure.DbQuery`1[ADONET4LINQtoENTITIES.Customer]' to type 'System.Data.Objects.ObjectQuery'.
Source=ADONET4LINQtoENTITIES
The error occurs in the line that defines the query variable:
var customers = from c in de.Customers
where c.Orders.Any(o => o.OrderAmount > 150)
select c;
string query = ((ObjectQuery)customers).ToTraceString();
My assumption is that ObjectQuery
is prompting the exception.
I tried string query = ((DbQuery)customers).ToString()
instead, which works in VS2013, but this resulted in the same exception.
Why does VS2015 throw exceptions with these query approaches?