Skip to content

Flatten AsQueryableResultOperator #2503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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