In “Programming Entity Framework”, 2nd edition by Julia Lerman, in chapter dedicated to Entity SQL, p. 115, we have the following example of using query builder method to do projection using EF 4.1 .Where and .Select with string parameters:
ObjectQuery<DbDataRecord> contacts = context.Contacts
.Where("it.FirstName='Robert'")
.Select("it.Title, it.FirstName, it.LastName");
I am using Entity Framework 6, .Net 4.6, VS 2015. The compiler complains that there are no .Where and .Select that accept string parameters, only lambdas. Is there any solution how to follow this book example?
The example appears to be about the old
ObjectQueryAPI, which shouldn't really be used now. It's still possible to use it with EF6.x though, with something like the following:That said, you really should use the lambda instead with the new
DbContextAPI.