Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not directly possible to filter on the first item of a collection relation (such as <code>Bs[0]</code>), for one because <code>ICollection&lt;B&gt;</code> does not have an indexer.</p> <p>However, it is possible to use predicates such as <code>Any</code> in a Dynamic Linq expression, such as:</p> <pre><code>result = list.Where("Bs.Any(Id = @0)", value); </code></pre> <p>which is equivalent to</p> <pre><code>result = from a in list where a.Bs.Any(b =&gt; b.Id == value) select a; </code></pre> <p>(This translates to an <code>EXISTS</code> query in SQL.)</p> <p>I think that's what you're after, not <code>Bs[0]</code>.</p> <hr> <p>The full list of supported predicates and aggregates for System.Linq.Dynamic seems to be: </p> <ul> <li><strong>Where</strong>(<em>condition</em>)</li> <li><strong>Any</strong>() and <strong>Any</strong>(<em>condition</em>)</li> <li><strong>All</strong>(<em>condition</em>)</li> <li><strong>Count</strong>() and <strong>Count</strong>(<em>condition</em>)</li> <li><strong>Max</strong>(<em>selector</em>)</li> <li><strong>Min</strong>(<em>selector</em>)</li> <li><strong>Sum</strong>(<em>selector</em>)</li> <li><strong>Average</strong>(<em>selector</em>)</li> </ul> <p>For <code>Bs[0].Id = @0</code> you'd need to have support for <strong>First</strong>(<em>condition</em>), which you could add to a private copy of System.Linq.Dynamic, by editing the interface <code>IEnumerableSignatures</code>, adding</p> <pre><code>void First(); void First(bool predicate); void FirstOrDefault(); void FirstOrDefault(bool predicate); </code></pre> <p>(Adding Last(OrDefault) and Single(OrDefault) as well would be a logical step IMHO.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload