Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use something like</p> <pre><code>var q = (from d in db.Direccion where d.Activo == true select new { IdEstructura = d.IdDireccion, Descripcion = d.Descripcion, IdPadre = 0, lstEstructurasHijos = d.Cliente.Select(C =&gt; new { IdEstructura = C.IdCliente, Descripcion = C.Descripcion, IdPadre = C.IdDireccion, lstEstructurasHijos = C.Campana.Select(Ca =&gt; new { IdEstructura = Ca.IdCampana, Descripcion = Ca.Descripcion, IdPadre = Ca.IdCliente, lstEstructurasHijos = Ca.Servicio.Select(S =&gt; new { IdEstructura = S.IdServicio, Descripcion = S.Descripcion, IdPadre = S.IdCampana }) }) }) } into query select query).ToList(); var result = q.Select(d=&gt;new Estructura { IdEstructura = d.IdEstructura, Descripcion = d.Descripcion, IdPadre = d.IdPadre, lstEstructurasHijos = d.Cliente.Select(C =&gt; new Estructura { IdEstructura = C.IdEstructura, Descripcion = C.Descripcion, IdPadre = C.IdPadre, lstEstructurasHijos = C.Campana.Select(Ca =&gt; new Estructura { IdEstructura = Ca.IdEstructura, Descripcion = Ca.Descripcion, IdPadre = Ca.IdPadre, lstEstructurasHijos = Ca.Servicio.Select(S =&gt; new Estructura { IdEstructura = S.IdEstructura, Descripcion = S.Descripcion, IdPadre = S.IdPadre }) }) }) } </code></pre> <p>It's work for me</p> <blockquote> <p>How can I Defined a default empty hashset for this Ienumerable?</p> </blockquote> <p>Just delete <code>lstEstructurasHijos = new HashSet&lt;Estructura&gt;()</code> from query and allow constructor initialize empty list</p> <pre><code> public class Estructura { public Estructura() { //!!! this.lstEstructurasHijos = new HashSet&lt;Estructura&gt;(); } //... } </code></pre>
    singulars
    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.
    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