-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InMemory: Avoid N+1 queries for Include
Don't send shapers to ServerQueryExpression Laying ground work for collection projection Part of #16963
- Loading branch information
Showing
10 changed files
with
235 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.ResultEnumerable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal | ||
{ | ||
public partial class InMemoryQueryExpression | ||
{ | ||
private sealed class ResultEnumerable : IEnumerable<ValueBuffer> | ||
{ | ||
private readonly Func<ValueBuffer> _getElement; | ||
|
||
public ResultEnumerable(Func<ValueBuffer> getElement) | ||
{ | ||
_getElement = getElement; | ||
} | ||
|
||
public IEnumerator<ValueBuffer> GetEnumerator() => new ResultEnumerator(_getElement()); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
|
||
private sealed class ResultEnumerator : IEnumerator<ValueBuffer> | ||
{ | ||
private readonly ValueBuffer _value; | ||
private bool _moved; | ||
|
||
public ResultEnumerator(ValueBuffer value) | ||
{ | ||
_value = value; | ||
_moved = _value.IsEmpty; | ||
} | ||
|
||
public bool MoveNext() | ||
{ | ||
if (!_moved) | ||
{ | ||
_moved = true; | ||
|
||
return _moved; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public void Reset() | ||
{ | ||
_moved = false; | ||
} | ||
|
||
object IEnumerator.Current => Current; | ||
|
||
public ValueBuffer Current => !_moved ? ValueBuffer.Empty : _value; | ||
|
||
void IDisposable.Dispose() | ||
{ | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.