Eager loading in EntityFramework with DbContext.Database.SqlQuery

≡放荡痞女 提交于 2019-11-29 10:06:12

DbSet.SqlQuery works differently than Database.SqlQuery. The method on DbSet applies to the given entity set. It has to return entities of the given type and by default the returned entities will be tracked. Database.SqlQuery can return any object (possibly not an entity) and the returned objects are never tracked by the context. You may also want to take a look at msdn to compare both methods:

Database.SqlQuery - http://msdn.microsoft.com/en-us/library/gg679117(v=vs.103).aspx

DbSet.SqlQuery - http://msdn.microsoft.com/en-us/library/system.data.entity.dbset.sqlquery(v=VS.103).aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!