C# Nhibernate how to join queryover one to many -


i new nhibernate query. have oracle table 1 many relationship have mentioned below. have done fluent nhibernate mapping , trying run below query keep getting error saying chinfo_id not valid. can me doing wrong here.

    var query = session.queryover(() => logalias)                     .inner.joinqueryover(()=>logalias.chinfo, ()=>chinfoalias)                     .where(()=>logalias.regdate.isbetween(fromdate).and(todate))                     .future<log>();      return query.tolist(); 

tables:

ch_info

ch_no name 

log

portid regdate ch_no 

class , fluentnhibernate maps:

public class log {     public virtual int portid { get; set; }     public virtual datetime regdate { get; set; }     public virtual chinfo chinfo { get; set; } }  public class chinfo {     public chinfo()     {         logs = new list<log>();     }      public virtual string id { get; set; }     public virtual string name { get; set; }     public virtual ilist<log> logs { get; set; }         }  public class logmap : classmap<log> {     public logmap()     {         table("log");          compositeid()             .keyproperty(x => x.portid,"portid")             .keyproperty(x => x.regdate, "regdate");          references(x => x.chinfo);     } }    public class chinfomap : classmap<chinfo> {     public chinfomap()     {         table("ch_info");          id(x => x.id).generatedby.assigned().column("ch_no");         map(x => x.name).column("name");         hasmany(x => x.logs)             .inverse()             .cascade.all();     } } 

i solved specifying column name in references in logmap.

public class logmap : classmap<log> {     public logmap()     {         table("log");          compositeid()             .keyproperty(x => x.portid,"portid")             .keyproperty(x => x.regdate, "regdate");          references(x => x.chinfo).columne("ch_no");     } } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -