Skip to content

Commit

Permalink
Flatten AsQueryableResultOperator (#2503)
Browse files Browse the repository at this point in the history
Fixes #2471
  • Loading branch information
hazzik authored Aug 30, 2020
1 parent 46a18cc commit f43dc6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/NHibernate.Test/Async/Linq/WhereSubqueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ where timesheet.Entries.AsQueryable().Any(e => !new[] { 1 }.Contains(e.Id))
Assert.That(query.Count, Is.EqualTo(2));
}

[Test(Description = "GH-2471")]
public async Task TimeSheetsWithStringContainsSubQueryWithAsQueryableAfterWhereAsync()
{
var query = await ((
from timesheet in db.Timesheets
where timesheet.Entries.Where(e => e.Comments != null).AsQueryable().Any(e => e.Comments.Contains("testing"))
select timesheet).ToListAsync());

Assert.That(query.Count, Is.EqualTo(2));
}

[Test(Description = "NH-3002")]
public async Task HqlOrderLinesWithInnerJoinAndSubQueryAsync()
{
Expand Down
11 changes: 11 additions & 0 deletions src/NHibernate.Test/Linq/WhereSubqueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ where timesheet.Entries.AsQueryable().Any(e => !new[] { 1 }.Contains(e.Id))
Assert.That(query.Count, Is.EqualTo(2));
}

[Test(Description = "GH-2471")]
public void TimeSheetsWithStringContainsSubQueryWithAsQueryableAfterWhere()
{
var query = (
from timesheet in db.Timesheets
where timesheet.Entries.Where(e => e.Comments != null).AsQueryable().Any(e => e.Comments.Contains("testing"))
select timesheet).ToList();

Assert.That(query.Count, Is.EqualTo(2));
}

[Test(Description = "NH-3002")]
public void HqlOrderLinesWithInnerJoinAndSubQuery()
{
Expand Down
4 changes: 3 additions & 1 deletion src/NHibernate/Linq/Visitors/SubQueryFromClauseFlattener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Remotion.Linq.Clauses;
using Remotion.Linq.Clauses.Expressions;
using Remotion.Linq.Clauses.ExpressionVisitors;
using Remotion.Linq.Clauses.ResultOperators;
using Remotion.Linq.EagerFetching;

namespace NHibernate.Linq.Visitors
Expand All @@ -15,7 +16,8 @@ public class SubQueryFromClauseFlattener : NhQueryModelVisitorBase
typeof(LockResultOperator),
typeof(FetchLazyPropertiesResultOperator),
typeof(FetchOneRequest),
typeof(FetchManyRequest)
typeof(FetchManyRequest),
typeof(AsQueryableResultOperator)
};

public static void ReWrite(QueryModel queryModel)
Expand Down

0 comments on commit f43dc6d

Please sign in to comment.