Entity Framework's navigation properties are null after sort by nullable
<p>I use the following code to convert order by expressions so nullable columns can be ordered by as well.</p>

<pre><code>protected virtual Expression&lt;Func&lt;T, object&gt;&gt; GetSorting(string ordering)
{
        Expression&lt;Func&lt;T, object&gt;&gt; expression = default(Expression&lt;Func&lt;T, object&gt;&gt;);
        IEnumerable&lt;Order&gt; sortObjects = string.IsNullOrEmpty(ordering) ? null : JsonConvert.DeserializeObject&lt;IEnumerable&lt;Order&gt;&gt;(ordering);
        if (sortObjects != null)
        {
            foreach (Order sortObject in sortObjects)
            {
                Expression&lt;Func&lt;T, object&gt;&gt; currentExpression = this.GetExpression(sortObject.Property);
                expression = this.CombineExpressions(expression, currentExpression);
            }
        }

        return expression;
}

private Expression&lt;Func&lt;T, object&gt;&gt; GetExpression(string propertyName)
{
        Type type = typeof(T);
        ParameterExpression parameter = Expression.Parameter(type, "x");
        MemberExpression propertyReference = Expression.Property(parameter, propertyName);
        Expression conversion = Expression.Convert(propertyReference, typeof(object));
        Expression&lt;Func&lt;T, object&gt;&gt; currentExpression = Expression.Lambda&lt;Func&lt;T, object&gt;&gt;(conversion, new[] { parameter });
        return currentExpression;

}

private Expression&lt;Func&lt;T, object&gt;&gt; CombineExpressions(Expression&lt;Func&lt;T, object&gt;&gt; expression, Expression&lt;Func&lt;T, object&gt;&gt; currentExpression)
{
        if (expression == default(Expression&lt;Func&lt;T, object&gt;&gt;))
        {
            expression = currentExpression;
        }
        else
        {
            // Combine the two expressions' body together
            BinaryExpression body = Expression.AndAlso(expression.Body, currentExpression.Body);
            ParameterExpression[] parameters = new ParameterExpression[1] { Expression.Parameter(typeof(T), expression.Parameters.First().Name) };

            // Convert the BinaryExpression to the requested type
            Expression&lt;Func&lt;T, object&gt;&gt; lambda = Expression.Lambda&lt;Func&lt;T, object&gt;&gt;(body, parameters);

            expression = lambda;
        }

        return expression;
}
</code></pre>

<p>This code works perfectly for all non-navigation properties but it seems as if the navigation properties aren't queried anymore. I use a Select expression to load the navigation properties, like so:</p>

<pre><code>protected override Expression&lt;Func&lt;Resource, ResourceViewModel&gt;&gt; Selector
{
        get
        {
            return (x) =&gt; new ResourceViewModel()
            {
                ResourceId = x.ResourceId,
                DisplayName = x.DisplayName,                  
                ResourceType = x.ResourceType != null ? x.ResourceType.Name : string.Empty,
            }
        }
}
</code></pre>

<p>If I don't have anything to order by, the navigation properties are loaded. But as soon as there is anything to order by, the navigation property is null. If I would skip the ternary operation and straightly go to the ResourceType.Name property, I'd get an exception telling me the lambda_method has thrown a NullReference exception.</p>

<p>I know ordering navigation properties doesn't work as such but that's not the problem. Ordering by 'regular' properties causes the problem. </p>

<p>Any thoughts on this?</p>