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 something you’ll do often, but now you know that the capability is there when you need it. So why don’t you take a break before you complete the Review and we move on?


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset