나는NHibernate에 JoinQueryOver과 게으른로드
var query = _session.QueryOver<TEntity>().JoinQueryOver<PropertyMultTable>(p => p.Properties).Where(propertyPredicate).List();
이 쿼리는 다음 SQL
select this_.BaseEntity_id as BaseId0_1_ ,
this_1_.Label as Label0_1_ ,
this_1_.Description as Descript3_0_1_ ,
this_1_.CreatedDate as CreatedD4_0_1_ ,
this_.Width as Width2_1_ ,
this_.Height as Height2_1_ ,
this_.Duration as Duration2_1_ ,
propertymu1_.id as id4_0_ ,
propertymu1_.Name as Name4_0_ ,
propertymu1_1_.DateTimeValue as DateTime2_5_0_ ,
propertymu1_2_.IntegerValue as IntegerV2_6_0_ ,
propertymu1_3_.DecimalValue as DecimalV2_7_0_ ,
propertymu1_4_.StringValue as StringVa2_8_0_
from [Video] this_
inner join [BaseEntity] this_1_ on this_.BaseEntity_id = this_1_.BaseId
inner join [PropertyMultTable] propertymu1_ on this_.BaseEntity_id = propertymu1_.BaseEntity_id
left outer join DateTimeValues propertymu1_1_ on propertymu1_.id = propertymu1_1_.PropertyMultTable_id
left outer join IntegerValues propertymu1_2_ on propertymu1_.id = propertymu1_2_.PropertyMultTable_id
left outer join DecimalValues propertymu1_3_ on propertymu1_.id = propertymu1_3_.PropertyMultTable_id
left outer join StringValues propertymu1_4_ on propertymu1_.id = propertymu1_4_.PropertyMultTable_id
where (propertymu1_2_.IntegerValue >= 459144
and propertymu1_2_.IntegerValue <= 691982
)
를 생성하는 쿼리를해야하지만 등록하지 않고, 단지 엔터티 싶어.
select this_.BaseEntity_id as BaseId0_1_ ,
this_1_.Label as Label0_1_ ,
this_1_.Description as Descript3_0_1_ ,
this_1_.CreatedDate as CreatedD4_0_1_ ,
this_.Width as Width2_1_ ,
this_.Height as Height2_1_ ,
this_.Duration as Duration2_1_
from [Video] this_
inner join [BaseEntity] this_1_ on this_.BaseEntity_id = this_1_.BaseId
inner join [PropertyMultTable] propertymu1_ on this_.BaseEntity_id = propertymu1_.BaseEntity_id
left outer join DateTimeValues propertymu1_1_ on propertymu1_.id = propertymu1_1_.PropertyMultTable_id
left outer join IntegerValues propertymu1_2_ on propertymu1_.id = propertymu1_2_.PropertyMultTable_id
left outer join DecimalValues propertymu1_3_ on propertymu1_.id = propertymu1_3_.PropertyMultTable_id
left outer join StringValues propertymu1_4_ on propertymu1_.id = propertymu1_4_.PropertyMultTable_id
where (propertymu1_2_.IntegerValue >= 459144
and propertymu1_2_.IntegerValue <= 691982
)
하거나, 심지어 더 나은,이 같은 :
select distinct this_.BaseEntity_id as BaseId0_1_ ,
this_1_.Label as Label0_1_ ,
this_1_.Description as Descript3_0_1_ ,
this_1_.CreatedDate as CreatedD4_0_1_ ,
this_.Width as Width2_1_ ,
this_.Height as Height2_1_ ,
this_.Duration as Duration2_1_
from [Video] this_
inner join [BaseEntity] this_1_ on this_.BaseEntity_id = this_1_.BaseId
inner join [PropertyMultTable] propertymu1_ on this_.BaseEntity_id = propertymu1_.BaseEntity_id
left outer join IntegerValues propertymu1_2_ on propertymu1_.id = propertymu1_2_.PropertyMultTable_id
where (propertymu1_2_.IntegerValue >= 459144
and propertymu1_2_.IntegerValue <= 691982
)
내가 유창함 NHibernate에이 작업을 수행 할 수 있습니다,이 같은 SQL이 필요하십니까? 답변 주셔서 감사합니다.
당신이 비디오의 클래스 선언을 추가 할 수 있습니까? – Baz1nga
비디오는 Width, Height 및 Duration의 3 가지 속성을 가진 클래스이며 Id, Label, Description 및 CreatedDate 속성 만 포함하는 BaseEntity에서 파생됩니다. – msi
Fluent NHibernate는 쿼리를 만들지 않고 매핑을 만드는 데 사용됩니다 . –