Executing queries directly

Although you could, at least theoretically, use ExecuteStoreCommand() to run queries on the server, doing so doesn’t make much sense, because the method only returns the number of records affected, not the records themselves. For querying, the ObjectContext class exposes the ExecuteStoreQuery<T>() method, and the equivalent DbSet<T> method is SqlQuery():

Image

Image Take A Break

We’ve only just touched the surface of the capabilities both ObjectContext and DbContext provide for executing commands directly on the server. It’s not ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.