私はこのクエリは、次のSQLNHibernateはJoinQueryOverと遅延ロード
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
)
をクエリ
var query = _session.QueryOver<TEntity>().JoinQueryOver<PropertyMultTable>(p => p.Properties).Where(propertyPredicate).List();
を生成しているが、私はプロパティせず、唯一のエンティティを取得したいです。このように、
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
)
や、さえはるかに良い::だから、私はこのようなSQLが必要
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はでこれを行うことができますか?回答ありがとう。
あなたがビデオのクラス宣言を追加することはできますか? – Baz1nga
ビデオは幅、高さ、および長さの3つのプロパティを持つクラスであり、Id、ラベル、説明、およびCreatedDateのプロパティのみを含むBaseEntityから派生したものです – msi
流暢なNHibernateはクエリを作成するのではなく、 。 –