I could not find an answer on the Internet.
我在互联网上找不到答案。
Let's suppose I have a DbContext
, and I just select all the entities from it. I don't add, update or delete any entity on the DbSet
.
假设我有一个DbContext,我只需从中选择所有实体。我不添加,更新或删除DbSet上的任何实体。
If I call SaveChanges
afterwards on the DbSet
. Does it actually waste resources establishing a connection and other stuff even If I did not made any changes to the DbSet
?
如果我之后在DbSet上调用SaveChanges。它是否真的浪费资源建立连接和其他东西即使我没有对DbSet做任何更改?
Is it smart enough to detect if a change was made or not, and behave differently?
是否足够智能来检测是否进行了更改,并且表现不同?
1 个解决方案
#1
18
It uses EntityState to determine that there is nothing to commit and so does not waste resources.
它使用EntityState来确定没有任何提交,因此不会浪费资源。
http://msdn.microsoft.com/en-us/library/system.data.entitystate%28v=vs.110%29.aspx
#1
18
It uses EntityState to determine that there is nothing to commit and so does not waste resources.
它使用EntityState来确定没有任何提交,因此不会浪费资源。
http://msdn.microsoft.com/en-us/library/system.data.entitystate%28v=vs.110%29.aspx