How do I combine IQueryables into a single call?
<p>I'd like to pass <code>IQueryable</code> as a parameter to a function that would then call the Entity Framework provider to execute a query as follows:</p>

<pre><code>public ICollection&lt;MyRowType&gt; RunCommand(IQueryable&lt;MyRowType&gt; query)
{
    using (var db = new MyDbContext())
    {
        var result = db.MyRowType
            .Include(r =&gt; r.RelatedTableA)
            .Include(r =&gt; r.RelatedTableB)
            .Include(r =&gt; r.RelatedTableC)

            // How do I make the value in `query` run here?

            .ToList();
    }
}
</code></pre>

<p>I'm basically wrapping my database calls to this method to return all the necessary includes but I don't want to lose the flexibility of making custom queries via <code>IQueryable&lt;MyRowType&gt;</code>.</p>

<p>Here's an example of what I'd like to achieve:</p>

<pre><code>public ICollection&lt;MyRowType&gt; SomeOtherMethod(string id, SomeValue value = null, SomeOtherValue  otherValue = null)
{
    var query = Enumerable.Empty&lt;MyRowType&gt;()
        .Where(r =&gt; r.Id == di);

    if (value != null)
        query = query.Where(r =&gt; r.PropertyOne == value);

    if (otherValue != null)
        query = query.Where(r =&gt; r.PropertyTwo == otherValue);

    return RunCommand(query);     
}
</code></pre>

<p>Answer update:</p>

<p>I combined the answers of <a href="https://stackoverflow.com/a/34970242/160823">Yacoub Massad</a> and <a href="https://stackoverflow.com/a/34970378/160823">dasblinkenlight</a> into these two methods:</p>

<pre><code>public static ICollection&lt;MyRowType&gt; RunCommand(Expression&lt;Func&lt;MyRowType, bool&gt;&gt; condition)
{
    return Get(t =&gt; t.Where(condition));
}

public static ICollection&lt;MyRowType&gt; RunCommand(Func&lt;IQueryable&lt;MyRowType&gt;, IQueryable&lt;MyRowType&gt;&gt; query)
{
    using (var db = new DbContext())
    {
        var includes = db.MyRowType
            .Include(r =&gt; r.RelatedTableA)
            .Include(r =&gt; r.RelatedTableB)
            .Include(r =&gt; r.RelatedTableC)

        var result = query(includes)
            .ToList();

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