Include()
does not change query
instance, it returns new one. You need to assign it back to query
:
protected void LoadNavigationProperty(ref IQueryable<T> query, Expression<Func<T, object>>[] navigationProperties)
{
if ((query != null) && (navigationProperties != null))
{
foreach (var navigationProperty in navigationProperties)
{
query = query.Include<T, object>(navigationProperty);
}
}
}