“select * from customer where age > 18 and age < 65”
Any more of an abstraction and easier than
from context.Customer where c.Age > 18 && c.Age < 65
With one it’s a magic string where you could have typos. With the other you get compile time syntax checking.
If you had an in memory list you would write:
var seniors = from c in customers where c.Age > 65
If you were using an RDMS you would write:
var customers = context.Customers
var seniors = from c in customers where c.Age > 65
If you were using Mongo you would write:
var customers = database.GetCollection<Customers>(“Customers”)
var seniors = from c in customers where c.Age > 65
In each case, the query would be translated appropriately - as in memory code, SQL, or MongoQuery respectively.