0
Gentlemen, my problem apparently is simple, I must be doing or forgetting something and I just can’t see the error. Can you help me?
I have the 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 it this way:
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 Customer object with the filled Meter list. I just make a:
Session.Query<Cliente>().Fetch(x => x.ListaMedidores).ToList();
And the list of meters is empty, even though there are records in the bank. I would be grateful for any help/suggestion.
It would be important for you to post the mistake you’re making. Don’t know Fluent or Nhibernate, but posting the error, colleagues here will better understand your problem. Make an edit and post the error.
– pnet
Hi, there is no error (Exception). The query runs normally but does not return what I want. It is bugged.. have tried several ways to map and none of them solved the problem...
– Marllon Nasser