在没有DB调用的情况下获取对象引用 [英] Getting an object reference without a DB call

查看:85
本文介绍了在没有DB调用的情况下获取对象引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在没有DB往返的情况下获得对象引用,就像使用
ISession.Load(id)的NHibernate一样?

Is it possible to get an object reference without a DB roundtrip, like one would do with NHibernate using ISession.Load(id)?

推荐答案

您好,

根据您想要达到的目标,您可能会发现一些有用的信息:

Depending on what you want to achieve here is some info you may find useful:


  • 如果您想针对内存数据进行测试,请查看此帖子;  http://romiller.com/2010/09/07 / ef-ctp4-tips-tricks-testing-with-fake-dbcontext /
  • 如果要查询已经从数据库加载的上下文中的数据,那么就像myContext。设置< Product>()。如果数据尚未加载,查找(id)将仅访问数据库
  • 您还可以查询已通过DbContext加载的数据。 ChangeTracker.Entries()方法

如果这不能回答你的问题,请告诉我。

Let me know if this doesn't answer your question.

~Rowan


这篇关于在没有DB调用的情况下获取对象引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆