Entity Framework 5 - Is it possible to load relationships (associations) without lazy and eager loading?

狂风中的少年 提交于 2019-12-25 04:58:09

问题


I'm trying to develop a generic repository on Entity Framework 5 for get data from any table and I want to use disconnected context without lazy and eager loading. Is it possible? I'm using the code below, but it doesn't works:

T it's entity type.

public IList<T> GetData(Expression<Func<T, bool>> expression)
{
        using (var context = new Context())
        {
            return context.Set<T>().Where(expression).ToList();
        }
}

Just the main entity it's loaded, the relationships no.

来源:https://stackoverflow.com/questions/19393748/entity-framework-5-is-it-possible-to-load-relationships-associations-without

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