Skip to content

Commit 5e089e6

Browse files
committed
test cleanup
1 parent b75d6a5 commit 5e089e6

File tree

2 files changed

+134
-52
lines changed

2 files changed

+134
-52
lines changed

src/NHibernate.Test/Async/Criteria/EntityJoinCriteriaTest.cs

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public async Task CanJoinNotAssociatedEntityAsync()
3838
{
3939
EntityComplex entityComplex = null;
4040
EntityWithNoAssociation root = null;
41-
root = await (session.QueryOver<EntityWithNoAssociation>(() => root)
42-
.JoinEntityAlias(() => entityComplex, Restrictions.Where(() => root.Complex1Id == entityComplex.Id), JoinType.InnerJoin).Take(1)
41+
root = await (session.QueryOver(() => root)
42+
.JoinEntityAlias(() => entityComplex, Restrictions.Where(() => root.Complex1Id == entityComplex.Id)).Take(1)
4343
.SingleOrDefaultAsync());
4444
entityComplex = await (session.LoadAsync<EntityComplex>(root.Complex1Id));
4545

@@ -76,8 +76,28 @@ public async Task CanJoinEntityQueryOverAsync()
7676
{
7777
EntityComplex ejQueryOver = null;
7878
EntityWithNoAssociation root = null;
79-
root = await (session.QueryOver<EntityWithNoAssociation>(() => root)
80-
.JoinEntityQueryOver(() => ejQueryOver, Restrictions.Where(() => root.Complex1Id == ejQueryOver.Id), JoinType.InnerJoin)
79+
root = await (session.QueryOver(() => root)
80+
.JoinEntityQueryOver(() => ejQueryOver, Restrictions.Where(() => root.Complex1Id == ejQueryOver.Id))
81+
.Take(1)
82+
.SingleOrDefaultAsync());
83+
ejQueryOver = await (session.LoadAsync<EntityComplex>(root.Complex1Id));
84+
85+
Assert.That(NHibernateUtil.IsInitialized(ejQueryOver), Is.True);
86+
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
87+
}
88+
}
89+
90+
//check JoinEntityQueryOver - JoinQueryOver analog for entity join
91+
[Test]
92+
public async Task CanJoinEntityQueryOver_ExpressionAsync()
93+
{
94+
using (var sqlLog = new SqlLogSpy())
95+
using (var session = OpenSession())
96+
{
97+
EntityComplex ejQueryOver = null;
98+
EntityWithNoAssociation root = null;
99+
root = await (session.QueryOver(() => root)
100+
.JoinEntityQueryOver(() => ejQueryOver, () => root.Complex1Id == ejQueryOver.Id)
81101
.Take(1)
82102
.SingleOrDefaultAsync());
83103
ejQueryOver = await (session.LoadAsync<EntityComplex>(root.Complex1Id));
@@ -96,8 +116,8 @@ public async Task CanQueryOverForAssociationInNotAssociatedEntityAsync()
96116
{
97117
EntityComplex ejComplex = null;
98118
EntityWithNoAssociation root = null;
99-
root = await (session.QueryOver<EntityWithNoAssociation>(() => root)
100-
.JoinEntityQueryOver(() => ejComplex, Restrictions.Where(() => root.Complex1Id == ejComplex.Id), JoinType.InnerJoin)
119+
root = await (session.QueryOver(() => root)
120+
.JoinEntityQueryOver(() => ejComplex, () => root.Complex1Id == ejComplex.Id)
101121
.JoinQueryOver(ej => ej.Child1)
102122
.Take(1)
103123
.SingleOrDefaultAsync());
@@ -119,8 +139,8 @@ public async Task SimpleProjectionForEntityJoinAsync()
119139
{
120140
EntityComplex ejComplex = null;
121141
EntityWithNoAssociation root = null;
122-
var name = await (session.QueryOver<EntityWithNoAssociation>(() => root)
123-
.JoinEntityQueryOver(() => ejComplex, Restrictions.Where(() => root.Complex1Id == ejComplex.Id), JoinType.InnerJoin)
142+
var name = await (session.QueryOver(() => root)
143+
.JoinEntityQueryOver(() => ejComplex, () => root.Complex1Id == ejComplex.Id)
124144
.Select((e) => ejComplex.Name)
125145
.Take(1)
126146
.SingleOrDefaultAsync<string>());
@@ -141,9 +161,9 @@ public async Task EntityProjectionForEntityJoinAsync()
141161
EntityComplex root = null;
142162
EntityComplex st = null;
143163
var r = await (session
144-
.QueryOver<EntityComplex>(() => root)
164+
.QueryOver(() => root)
145165
.JoinAlias(c => c.SameTypeChild, () => st)
146-
.JoinEntityAlias(() => ejChild1, Restrictions.Where(() => ejChild1.Id == root.Child1.Id), JoinType.InnerJoin)
166+
.JoinEntityAlias(() => ejChild1, () => ejChild1.Id == root.Child1.Id)
147167
.Select(
148168
Projections.RootEntity(),
149169
Projections.Entity(() => st),
@@ -177,11 +197,11 @@ public async Task MixOfJoinsForAssociatedAndNotAssociatedEntitiesAsync()
177197
EntityComplex entityComplexForEjLevel1 = null;
178198
EntitySimpleChild ejLevel2OnEntityComplexForEjLevel1 = null;
179199
var obj = await (session
180-
.QueryOver<EntityComplex>(() => root)
200+
.QueryOver(() => root)
181201
.JoinEntityAlias(() => ejLevel1, Restrictions.Where(() => ejLevel1.Id == root.SameTypeChild.Id && root.Id != null), JoinType.LeftOuterJoin)
182202
.JoinAlias(() => ejLevel1.Child1, () => customChildForEjLevel1, JoinType.InnerJoin)
183203
.JoinAlias(() => ejLevel1.SameTypeChild, () => entityComplexForEjLevel1, JoinType.LeftOuterJoin)
184-
.JoinEntityAlias(() => ejLevel2OnEntityComplexForEjLevel1, Restrictions.Where(() => entityComplexForEjLevel1.Id == ejLevel2OnEntityComplexForEjLevel1.Id), JoinType.InnerJoin)
204+
.JoinEntityAlias(() => ejLevel2OnEntityComplexForEjLevel1, () => entityComplexForEjLevel1.Id == ejLevel2OnEntityComplexForEjLevel1.Id)
185205
.Where(() => customChildForEjLevel1.Id != null && ejLevel2OnEntityComplexForEjLevel1.Id != null)
186206
.Take(1)
187207
.SingleOrDefaultAsync<object>());
@@ -197,8 +217,8 @@ public async Task EntityJoinForCompositeKeyAsync()
197217
EntityWithCompositeId ejComposite = null;
198218
EntityWithNoAssociation root = null;
199219
root = await (session
200-
.QueryOver<EntityWithNoAssociation>(() => root)
201-
.JoinEntityAlias(() => ejComposite, Restrictions.Where(() => root.Composite1Key1 == ejComposite.Key.Id1 && root.Composite1Key2 == ejComposite.Key.Id2), JoinType.InnerJoin)
220+
.QueryOver(() => root)
221+
.JoinEntityAlias(() => ejComposite, () => root.Composite1Key1 == ejComposite.Key.Id1 && root.Composite1Key2 == ejComposite.Key.Id2)
202222
.Take(1).SingleOrDefaultAsync());
203223
var composite = await (session.LoadAsync<EntityWithCompositeId>(_entityWithCompositeId.Key));
204224

@@ -216,9 +236,9 @@ public async Task NullLeftEntityJoinAsync()
216236
{
217237
EntityComplex ejLeftNull = null;
218238
EntityWithNoAssociation root = null;
219-
root = await (session.QueryOver<EntityWithNoAssociation>(() => root)
220-
//add some non existent
221-
.JoinEntityAlias(() => ejLeftNull, Restrictions.Where(() => ejLeftNull.Id == null), JoinType.LeftOuterJoin)
239+
root = await (session.QueryOver(() => root)
240+
//add some non existent join condition
241+
.JoinEntityAlias(() => ejLeftNull, () => ejLeftNull.Id == null, JoinType.LeftOuterJoin)
222242
.Take(1)
223243
.SingleOrDefaultAsync());
224244

@@ -236,9 +256,9 @@ public async Task NullLeftEntityJoinWithEntityProjectionAsync()
236256
{
237257
EntityComplex ejLeftNull = null;
238258
EntityWithNoAssociation root = null;
239-
var objs = await (session.QueryOver<EntityWithNoAssociation>(() => root)
240-
//add some non existent
241-
.JoinEntityAlias(() => ejLeftNull, Restrictions.Where(() => ejLeftNull.Id == null), JoinType.LeftOuterJoin)
259+
var objs = await (session.QueryOver(() => root)
260+
//add some non existent join condition
261+
.JoinEntityAlias(() => ejLeftNull, () => ejLeftNull.Id == null, JoinType.LeftOuterJoin)
242262
.Select((e) => root.AsEntity(), e => ejLeftNull.AsEntity())
243263
.Take(1)
244264
.SingleOrDefaultAsync<object[]>());
@@ -261,12 +281,33 @@ public async Task EntityJoinForCustomEntityNameAsync()
261281
{
262282
EntityCustomEntityName ejCustomEntity= null;
263283
EntityWithNoAssociation root = null;
264-
root = await (session.QueryOver<EntityWithNoAssociation>(() => root)
284+
root = await (session.QueryOver(() => root)
265285
.JoinEntityAlias(() => ejCustomEntity, Restrictions.Where(() => ejCustomEntity.Id == root.CustomEntityNameId), JoinType.InnerJoin, customEntityName)
266286
.Take(1)
267287
.SingleOrDefaultAsync());
268288

269-
ejCustomEntity = await (session.LoadAsync<EntityCustomEntityName>(root.CustomEntityNameId));
289+
ejCustomEntity = (EntityCustomEntityName) await (session.LoadAsync(customEntityName, root.CustomEntityNameId));
290+
291+
Assert.That(NHibernateUtil.IsInitialized(ejCustomEntity), Is.True);
292+
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
293+
}
294+
}
295+
296+
[Test]
297+
public async Task EntityJoinForCustomEntityName_ExpressionAsync()
298+
{
299+
300+
using (var sqlLog = new SqlLogSpy())
301+
using (var session = OpenSession())
302+
{
303+
EntityCustomEntityName ejCustomEntity= null;
304+
EntityWithNoAssociation root = null;
305+
root = await (session.QueryOver(() => root)
306+
.JoinEntityAlias(() => ejCustomEntity, () => ejCustomEntity.Id == root.CustomEntityNameId, JoinType.InnerJoin, customEntityName)
307+
.Take(1)
308+
.SingleOrDefaultAsync());
309+
310+
ejCustomEntity = (EntityCustomEntityName) await (session.LoadAsync(customEntityName, root.CustomEntityNameId));
270311

271312
Assert.That(NHibernateUtil.IsInitialized(ejCustomEntity), Is.True);
272313
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
@@ -285,13 +326,13 @@ public async Task EntityJoinFoSubquery_JoinEntityAliasAsync()
285326
EntityComplex ejSub = null;
286327
EntityWithNoAssociation rootSub = null;
287328

288-
var subquery = QueryOver.Of<EntityWithNoAssociation>(() => rootSub)
329+
var subquery = QueryOver.Of(() => rootSub)
289330
.JoinEntityAlias(() => ejSub, () => rootSub.Complex1Id == ejSub.Id)
290331
.Where(r => ejSub.Name == ej.Name)
291332
.Select(x => ejSub.Id);
292333

293334
root = await (session.QueryOver(() => root)
294-
.JoinEntityAlias(() => ej, Restrictions.Where(() => root.Complex1Id == ej.Id))
335+
.JoinEntityAlias(() => ej, () => root.Complex1Id == ej.Id)
295336
.WithSubquery.WhereExists(subquery)
296337
.SingleOrDefaultAsync());
297338
ej = await (session.LoadAsync<EntityComplex>(root.Complex1Id));
@@ -313,13 +354,13 @@ public async Task EntityJoinFoSubquery_JoinQueryOverAsync()
313354
EntityComplex ejSub = null;
314355
EntityWithNoAssociation rootSub = null;
315356

316-
var subquery = QueryOver.Of<EntityWithNoAssociation>(() => rootSub)
357+
var subquery = QueryOver.Of(() => rootSub)
317358
.JoinEntityQueryOver(() => ejSub, () => rootSub.Complex1Id == ejSub.Id)
318359
.Where(x => x.Name == ej.Name)
319360
.Select(x => ejSub.Id);
320361

321362
root = await (session.QueryOver(() => root)
322-
.JoinEntityAlias(() => ej, Restrictions.Where(() => root.Complex1Id == ej.Id))
363+
.JoinEntityAlias(() => ej, () => root.Complex1Id == ej.Id)
323364
.WithSubquery.WhereExists(subquery)
324365
.SingleOrDefaultAsync());
325366
ej = await (session.LoadAsync<EntityComplex>(root.Complex1Id));

src/NHibernate.Test/Criteria/EntityJoinCriteriaTest.cs

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public void CanJoinNotAssociatedEntity()
2727
{
2828
EntityComplex entityComplex = null;
2929
EntityWithNoAssociation root = null;
30-
root = session.QueryOver<EntityWithNoAssociation>(() => root)
31-
.JoinEntityAlias(() => entityComplex, Restrictions.Where(() => root.Complex1Id == entityComplex.Id), JoinType.InnerJoin).Take(1)
30+
root = session.QueryOver(() => root)
31+
.JoinEntityAlias(() => entityComplex, Restrictions.Where(() => root.Complex1Id == entityComplex.Id)).Take(1)
3232
.SingleOrDefault();
3333
entityComplex = session.Load<EntityComplex>(root.Complex1Id);
3434

@@ -65,8 +65,28 @@ public void CanJoinEntityQueryOver()
6565
{
6666
EntityComplex ejQueryOver = null;
6767
EntityWithNoAssociation root = null;
68-
root = session.QueryOver<EntityWithNoAssociation>(() => root)
69-
.JoinEntityQueryOver(() => ejQueryOver, Restrictions.Where(() => root.Complex1Id == ejQueryOver.Id), JoinType.InnerJoin)
68+
root = session.QueryOver(() => root)
69+
.JoinEntityQueryOver(() => ejQueryOver, Restrictions.Where(() => root.Complex1Id == ejQueryOver.Id))
70+
.Take(1)
71+
.SingleOrDefault();
72+
ejQueryOver = session.Load<EntityComplex>(root.Complex1Id);
73+
74+
Assert.That(NHibernateUtil.IsInitialized(ejQueryOver), Is.True);
75+
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
76+
}
77+
}
78+
79+
//check JoinEntityQueryOver - JoinQueryOver analog for entity join
80+
[Test]
81+
public void CanJoinEntityQueryOver_Expression()
82+
{
83+
using (var sqlLog = new SqlLogSpy())
84+
using (var session = OpenSession())
85+
{
86+
EntityComplex ejQueryOver = null;
87+
EntityWithNoAssociation root = null;
88+
root = session.QueryOver(() => root)
89+
.JoinEntityQueryOver(() => ejQueryOver, () => root.Complex1Id == ejQueryOver.Id)
7090
.Take(1)
7191
.SingleOrDefault();
7292
ejQueryOver = session.Load<EntityComplex>(root.Complex1Id);
@@ -85,8 +105,8 @@ public void CanQueryOverForAssociationInNotAssociatedEntity()
85105
{
86106
EntityComplex ejComplex = null;
87107
EntityWithNoAssociation root = null;
88-
root = session.QueryOver<EntityWithNoAssociation>(() => root)
89-
.JoinEntityQueryOver(() => ejComplex, Restrictions.Where(() => root.Complex1Id == ejComplex.Id), JoinType.InnerJoin)
108+
root = session.QueryOver(() => root)
109+
.JoinEntityQueryOver(() => ejComplex, () => root.Complex1Id == ejComplex.Id)
90110
.JoinQueryOver(ej => ej.Child1)
91111
.Take(1)
92112
.SingleOrDefault();
@@ -108,8 +128,8 @@ public void SimpleProjectionForEntityJoin()
108128
{
109129
EntityComplex ejComplex = null;
110130
EntityWithNoAssociation root = null;
111-
var name = session.QueryOver<EntityWithNoAssociation>(() => root)
112-
.JoinEntityQueryOver(() => ejComplex, Restrictions.Where(() => root.Complex1Id == ejComplex.Id), JoinType.InnerJoin)
131+
var name = session.QueryOver(() => root)
132+
.JoinEntityQueryOver(() => ejComplex, () => root.Complex1Id == ejComplex.Id)
113133
.Select((e) => ejComplex.Name)
114134
.Take(1)
115135
.SingleOrDefault<string>();
@@ -130,9 +150,9 @@ public void EntityProjectionForEntityJoin()
130150
EntityComplex root = null;
131151
EntityComplex st = null;
132152
var r = session
133-
.QueryOver<EntityComplex>(() => root)
153+
.QueryOver(() => root)
134154
.JoinAlias(c => c.SameTypeChild, () => st)
135-
.JoinEntityAlias(() => ejChild1, Restrictions.Where(() => ejChild1.Id == root.Child1.Id), JoinType.InnerJoin)
155+
.JoinEntityAlias(() => ejChild1, () => ejChild1.Id == root.Child1.Id)
136156
.Select(
137157
Projections.RootEntity(),
138158
Projections.Entity(() => st),
@@ -166,11 +186,11 @@ public void MixOfJoinsForAssociatedAndNotAssociatedEntities()
166186
EntityComplex entityComplexForEjLevel1 = null;
167187
EntitySimpleChild ejLevel2OnEntityComplexForEjLevel1 = null;
168188
var obj = session
169-
.QueryOver<EntityComplex>(() => root)
189+
.QueryOver(() => root)
170190
.JoinEntityAlias(() => ejLevel1, Restrictions.Where(() => ejLevel1.Id == root.SameTypeChild.Id && root.Id != null), JoinType.LeftOuterJoin)
171191
.JoinAlias(() => ejLevel1.Child1, () => customChildForEjLevel1, JoinType.InnerJoin)
172192
.JoinAlias(() => ejLevel1.SameTypeChild, () => entityComplexForEjLevel1, JoinType.LeftOuterJoin)
173-
.JoinEntityAlias(() => ejLevel2OnEntityComplexForEjLevel1, Restrictions.Where(() => entityComplexForEjLevel1.Id == ejLevel2OnEntityComplexForEjLevel1.Id), JoinType.InnerJoin)
193+
.JoinEntityAlias(() => ejLevel2OnEntityComplexForEjLevel1, () => entityComplexForEjLevel1.Id == ejLevel2OnEntityComplexForEjLevel1.Id)
174194
.Where(() => customChildForEjLevel1.Id != null && ejLevel2OnEntityComplexForEjLevel1.Id != null)
175195
.Take(1)
176196
.SingleOrDefault<object>();
@@ -186,8 +206,8 @@ public void EntityJoinForCompositeKey()
186206
EntityWithCompositeId ejComposite = null;
187207
EntityWithNoAssociation root = null;
188208
root = session
189-
.QueryOver<EntityWithNoAssociation>(() => root)
190-
.JoinEntityAlias(() => ejComposite, Restrictions.Where(() => root.Composite1Key1 == ejComposite.Key.Id1 && root.Composite1Key2 == ejComposite.Key.Id2), JoinType.InnerJoin)
209+
.QueryOver(() => root)
210+
.JoinEntityAlias(() => ejComposite, () => root.Composite1Key1 == ejComposite.Key.Id1 && root.Composite1Key2 == ejComposite.Key.Id2)
191211
.Take(1).SingleOrDefault();
192212
var composite = session.Load<EntityWithCompositeId>(_entityWithCompositeId.Key);
193213

@@ -205,9 +225,9 @@ public void NullLeftEntityJoin()
205225
{
206226
EntityComplex ejLeftNull = null;
207227
EntityWithNoAssociation root = null;
208-
root = session.QueryOver<EntityWithNoAssociation>(() => root)
209-
//add some non existent
210-
.JoinEntityAlias(() => ejLeftNull, Restrictions.Where(() => ejLeftNull.Id == null), JoinType.LeftOuterJoin)
228+
root = session.QueryOver(() => root)
229+
//add some non existent join condition
230+
.JoinEntityAlias(() => ejLeftNull, () => ejLeftNull.Id == null, JoinType.LeftOuterJoin)
211231
.Take(1)
212232
.SingleOrDefault();
213233

@@ -225,9 +245,9 @@ public void NullLeftEntityJoinWithEntityProjection()
225245
{
226246
EntityComplex ejLeftNull = null;
227247
EntityWithNoAssociation root = null;
228-
var objs = session.QueryOver<EntityWithNoAssociation>(() => root)
229-
//add some non existent
230-
.JoinEntityAlias(() => ejLeftNull, Restrictions.Where(() => ejLeftNull.Id == null), JoinType.LeftOuterJoin)
248+
var objs = session.QueryOver(() => root)
249+
//add some non existent join condition
250+
.JoinEntityAlias(() => ejLeftNull, () => ejLeftNull.Id == null, JoinType.LeftOuterJoin)
231251
.Select((e) => root.AsEntity(), e => ejLeftNull.AsEntity())
232252
.Take(1)
233253
.SingleOrDefault<object[]>();
@@ -250,12 +270,33 @@ public void EntityJoinForCustomEntityName()
250270
{
251271
EntityCustomEntityName ejCustomEntity= null;
252272
EntityWithNoAssociation root = null;
253-
root = session.QueryOver<EntityWithNoAssociation>(() => root)
273+
root = session.QueryOver(() => root)
254274
.JoinEntityAlias(() => ejCustomEntity, Restrictions.Where(() => ejCustomEntity.Id == root.CustomEntityNameId), JoinType.InnerJoin, customEntityName)
255275
.Take(1)
256276
.SingleOrDefault();
257277

258-
ejCustomEntity = session.Load<EntityCustomEntityName>(root.CustomEntityNameId);
278+
ejCustomEntity = (EntityCustomEntityName) session.Load(customEntityName, root.CustomEntityNameId);
279+
280+
Assert.That(NHibernateUtil.IsInitialized(ejCustomEntity), Is.True);
281+
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
282+
}
283+
}
284+
285+
[Test]
286+
public void EntityJoinForCustomEntityName_Expression()
287+
{
288+
289+
using (var sqlLog = new SqlLogSpy())
290+
using (var session = OpenSession())
291+
{
292+
EntityCustomEntityName ejCustomEntity= null;
293+
EntityWithNoAssociation root = null;
294+
root = session.QueryOver(() => root)
295+
.JoinEntityAlias(() => ejCustomEntity, () => ejCustomEntity.Id == root.CustomEntityNameId, JoinType.InnerJoin, customEntityName)
296+
.Take(1)
297+
.SingleOrDefault();
298+
299+
ejCustomEntity = (EntityCustomEntityName) session.Load(customEntityName, root.CustomEntityNameId);
259300

260301
Assert.That(NHibernateUtil.IsInitialized(ejCustomEntity), Is.True);
261302
Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected");
@@ -274,13 +315,13 @@ public void EntityJoinFoSubquery_JoinEntityAlias()
274315
EntityComplex ejSub = null;
275316
EntityWithNoAssociation rootSub = null;
276317

277-
var subquery = QueryOver.Of<EntityWithNoAssociation>(() => rootSub)
318+
var subquery = QueryOver.Of(() => rootSub)
278319
.JoinEntityAlias(() => ejSub, () => rootSub.Complex1Id == ejSub.Id)
279320
.Where(r => ejSub.Name == ej.Name)
280321
.Select(x => ejSub.Id);
281322

282323
root = session.QueryOver(() => root)
283-
.JoinEntityAlias(() => ej, Restrictions.Where(() => root.Complex1Id == ej.Id))
324+
.JoinEntityAlias(() => ej, () => root.Complex1Id == ej.Id)
284325
.WithSubquery.WhereExists(subquery)
285326
.SingleOrDefault();
286327
ej = session.Load<EntityComplex>(root.Complex1Id);
@@ -302,13 +343,13 @@ public void EntityJoinFoSubquery_JoinQueryOver()
302343
EntityComplex ejSub = null;
303344
EntityWithNoAssociation rootSub = null;
304345

305-
var subquery = QueryOver.Of<EntityWithNoAssociation>(() => rootSub)
346+
var subquery = QueryOver.Of(() => rootSub)
306347
.JoinEntityQueryOver(() => ejSub, () => rootSub.Complex1Id == ejSub.Id)
307348
.Where(x => x.Name == ej.Name)
308349
.Select(x => ejSub.Id);
309350

310351
root = session.QueryOver(() => root)
311-
.JoinEntityAlias(() => ej, Restrictions.Where(() => root.Complex1Id == ej.Id))
352+
.JoinEntityAlias(() => ej, () => root.Complex1Id == ej.Id)
312353
.WithSubquery.WhereExists(subquery)
313354
.SingleOrDefault();
314355
ej = session.Load<EntityComplex>(root.Complex1Id);

0 commit comments

Comments
 (0)