Need help mapping one-to-many but as one-to-one getting the last status as Property

24 views
Skip to first unread message

rcha...@controlnet.com.ar

unread,
Jun 11, 2018, 2:22:59 PM6/11/18
to Fluent NHibernate

Need help with my mapping , I've got lets say a "Anclajes" and another one that logs the Error of the "Anclajes" with Error_anclajeID|AnclajeId|Status|DateTime I need that when Get all "Anclajes" , the "Anclajes" only have 1 Property with the LastOrDefault Error from Gq_error_anclaje . This is what i came with so far but dont know how to tell it the get the last row

  public MapGq_anclajes():base()
    { 
        References(x => x.Status_Anclaje).Column("AnclajeId").ReadOnly().Not.LazyLoad();
    }

public class Gq_anclajes : _Gq_anclajes
{ 
    public virtual Gq_error_anclaje Error_Anclaje { get; set; } 
}

Right now im using this to get last status foreach "Anclaje"

 foreach(item in Anclajes){
 var error = Services.Get<ServGq_error_anclaje>()
.findBy(x => x.AnclajeId == item.AnclajeId)
.OrderByDescending(c => c.Modificado).FirstOrDefault();
 }
Reply all
Reply to author
Forward
0 new messages