Note that there are some explanatory texts on larger screens.

plurals
  1. PONhibernate query Entity based on child of child property
    primarykey
    data
    text
    <p>I have an entity which has as child entity which has a collection of entities on it. </p> <pre><code>public class Entity1 { public virtual Entity2 Entity2 {get; set} } public class Entity2 { private readonly IList&lt;Entity3&gt; _entity3s = new List&lt;Entity3&gt;(); public virtual IEnumerable&lt;Entity3&gt; GetEntity3s() { return _entity3s; } public virtual void RemoveEntity3(Entity3 entity3) { _entity3s.Remove(entity3); } public virtual void AddEntity3(Entity3 entity3) { if (!entity3.IsNew() &amp;&amp; _entity3s.Contains(entity3)) return; _entity3s.Add(entity3); } } public class Entity3 { public virtual int Id {get;set;} } </code></pre> <p>I have the Entity3.Id and I need all the Entity1s that match so something like</p> <pre><code>session.Query&lt;Entity1&gt;(x=&gt;x.Entity2.Entity3s.Any(y=&gt;y.Id = 500)); </code></pre> <p>I have tried linq as well as queryover and both choke on the "Any" command.<br> Can anyone steer me in the right direction?<br> &lt;--- Edit ----><br> Right so I guess I had a bunch of things wrong and now I've fixed them all and my query works if I expose the enumerable directly, however it does not work when I have my collection encapsulated as I do above.<br> the error I'm getting is </p> <blockquote> <p>Cannot parse expression '[-1].Entity2' as it has an unsupported type. Only query sources (that is, expressions that implement IEnumerable) and query operators can be parsed.<br> inner exception<br> Message "Expected a type implementing IEnumerable, but found '...Entity2'.\r\nParameter name: expression" string </p> </blockquote> <p>Thanks,</p> <p>Raif</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. 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