0
使用的ICriteria我使用開發中MVC3的應用條件NHibernate的 我有兩個表,我想執行的兩個也之間的連接,我想包括多個有條件的地方.. 我張貼的所有相關表,因此它會清除要求:如何包括多個凡在NHibernate的
First table is HobbyMaster:
HobbyId
HobbyName
Second Table is HobbyHome:
HobbyHomeId
HobbyHomeName
Third Table is HobbyDetail:
HobbyDetailId
HobbyId(Foreign Key)
HobbyHomeId(Foreign key)
Fourth Table is HobbyHomeAddress:
Id(primary key)
HobbyHomeId(Foreign key)
StateId(Foreign Key)
DistrictId(Foreign key)
Fifth Table is State:
stateid
statename
last Table is District:
districtid
districtname
我想寫這樣的查詢:
select * from HobbyHomeAddress hobadd,
HobbyDetail hobdet
where hobdet.HobbyId=hobbyid
and hobadd.HobbyId=hobdet.HobbyId
and hobadd.StateId=stateid;
我試過,但它不工作,也給我NU LL
hobbyhomeaddress = session.CreateCriteria(typeof(HobbyHomeAddress))
.CreateAlias("HobbyDetail", "HobbyDetail", NHibernate.SqlCommand.JoinType.InnerJoin)
.Add(Expression.Eq("HobbyID", hobbyid))
.Add(Restrictions.Eq("HobbyHomeAddress.HobbyHomeId", "HobbyDetail.HobbyHomeId"))
.Add(Expression.Eq("ProvincialState.ProvincialStateID", stateid))
.List<HobbyHomeAddress>();
我能夠得到的ID通過Ajax,但我不理解怎麼火以下查詢 請幫我