to disable the entity lazy load, The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
public static List<Menu> Get(int appid) { List<Menu> menuList = null; using(wechatEntities ctx=new wechatEntities()) { //disable lazyload ctx.Configuration.LazyLoadingEnabled = false; var tmp = from x in ctx.Menu where x.APPId==appid select x; menuList = tmp.ToList(); } return menuList; }
public static List<Menu> Get(int appid) { List<Menu> menuList = null; using(wechatEntities ctx=new wechatEntities()) { //or using include var tmp = from x in ctx.Menu.Include("Menu1") where x.APPId == appid select x; menuList = tmp.ToList(); } return menuList; }