-->

Entity Framework 5 - Is it possible to load relati

2019-08-18 05:48发布

问题:

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.