I have this Linq and what I tried to do to set the element into the hashset and doesn’t work what’s missing?? When I debugged the result always show me the property empty
var estructura = (from result in query
select new Estructura()
{
IdEstructura = result.Servicio.Campana.Cliente.Direccion.IdDireccion,
Descripcion = result.Servicio.Campana.Cliente.Direccion.Descripcion,
lstEstructurasHijos = new HashSet<Estructura>().Select(
C => new Estructura()
{
IdEstructura = result.Servicio.Campana.Cliente.IdCliente,
Descripcion = result.Servicio.Campana.Cliente.Descripcion,
lstEstructurasHijos = new HashSet<Estructura>().Select(
CA => new Estructura()
{
IdEstructura = result.Servicio.Campana.IdCampana,
Descripcion = result.Servicio.Campana.Descripcion,
lstEstructurasHijos = new HashSet<Estructura>().Select(
S => new Estructura()
{
IdEstructura = result.Servicio.IdServicio,
Descripcion = result.Servicio.Descripcion,
lstEstructurasHijos = new HashSet<Estructura>()
})
})
})
});
You are misusing the
selecton theHashSetlike this one:Of course a new
HashSetwon’t contain anything. This’s why you get empty HashSets.