Lambda .Where limitation to string
<p>I have this method:</p>

<pre><code>public List&lt;object&gt; GetThings(List&lt;Guid&gt; listOfGuids)
{
    var query = serviceContext.Xrm.crmEntity;
    bool anyTypeOfSearch = false; // use this to know if we have actually applied any search criteria.

    if(listOfGuids != null &amp;&amp; listOfGuids.Count &gt; 0)
    {
        query = query.Where(x =&gt; listOfGuids.Contains(x.lgc_muncipalityid.Id));
        anyTypeOfSearch = true;
    }

    var result = new List&lt;object&gt;();
    if(anyTypeOfSearch) // instead of a variable here, can i check if there are any whereconditions applied to the query?
        result = query
            .Select(x =&gt; new SupplierSearchResultModel()
            {
                Id = x.Id,
                Name = x.lgc_name,
            })
            .ToList();

    LogMessage("GetThings.Query", &lt;insert code to get query.Where condition tostring()&gt;);

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

<p>In the real code there are several different if structures with <code>.Where</code> conditions in them and sometimes a call can reach this code without any parameters. In this case I don't want to run the query as the result set would be huge. So I only want to run the query if at least once the <code>.Where()</code> condition has been applied. </p>

<p>Now my question is, can I check a lambda query variable for if it has any <code>.Where()</code> conditions applied without using an external bool like I am?</p>

<p>An alternate interesting usage point would be if there is some way to get some sort of <code>query.Where().ToString()</code> method that would show what conditions will be applied which could be logged in case of errors...</p>