Gentlemen, my problem is apparently simple, I must be doing or forgetting something and I just can not see the error. Can you help me?
I have class Cliente
:
public class Cliente {
public Cliente () { }
public virtual int ClienteId { get; set; }
public IList<Medidor> ListaMedidores { get; set; }
public virtual string NumeroMedidor { get; set; }
}
And the class Medidor
public class Medidor
{
public Medidor() { }
public virtual string NumeroMedidor { get; set; }
public virtual string MarcaMedidor { get; set; }
public virtual Cliente Cliente { get; set; }
}
I tried to map as follows:
public ClienteMap()
{
Map(x => x.NumeroMedidor).Column("CORE_NUMERO_MEDIDOR");
HasMany(x => x.ListaMedidores).KeyColumn("NUMERO_MEDIDOR").Inverse().Cascade.All();
}
public MedidorMap()
{
Table("medidor");
LazyLoad();
Id(x => x.NumeroMedidor).Column("NUMERO_MEDIDOR");
Map(x => x.TipoMedidor).Column("TIPO_MEDIDOR");
References(x => x.Cliente).Column("CORE_NUMERO_MEDIDOR");
}
My goal is to bring the Client object with the completed Meter list. I simply do one:
Session.Query<Cliente>().Fetch(x => x.ListaMedidores).ToList();
And the meter list comes empty even though you have records in the bank. I'll be grateful for any kind of help / suggestion.