包括。不知道怎么做吗? [英] Include. Does anyonw knows how to do this?
本文介绍了包括。不知道怎么做吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我通过Id获得通用实体:
public T GetById(Int32 id) {
String table = typeof(T).Name;
EntityKey key = new EntityKey(_context.DefaultContainerName +"。" + table," Id",id);
return(T)_context.GetObjectByKey(key);
} // GetById
如何包含与T对象相关的所有记录?
我知道我应该使用包括但由于这是通用对象,我不知道它与哪些表有关。
我需要找到它。
谢谢,
Miguel < br <>
解决方案
使用延迟绑定是否会导致任何问题,或者您的架构是否可以接受?
您可以检查< a href ="http://blogs.msdn.com/jkowalski/archive/2008/05/12/transparent-lazy-loading-for-entity-framework-part-1.aspx"> http://blogs.msdn的.com / jkowalski /存档/ 2008/05/12 /透明延迟加载换实体框架部分-1.aspx
Hello,
I am getting a generic entity by Id:
public T GetById(Int32 id) {
String table = typeof(T).Name;
EntityKey key = new EntityKey(_context.DefaultContainerName + "." + table, "Id", id);
return (T)_context.GetObjectByKey(key);
} // GetById
How can I include all the records that are related to T object?
I know I should use Include but since this is generic object I don't know which tables it is related to.
I need to find it out.
Thanks,
Miguel
解决方案
Does using lazy binding causes any problem, or acceptable for your architecture?
You can check http://blogs.msdn.com/jkowalski/archive/2008/05/12/transparent-lazy-loading-for-entity-framework-part-1.aspx
这篇关于包括。不知道怎么做吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文