Exemplo n.º 1
0
                public TResult selector(TOuter jo)
                {
                    var ko = context.outerKeySelector(jo);


                    var e = context.inner.Where(
                        ji => c.Compare(ko, context.innerKeySelector(ji)) == 0
                        );

                    var r = context.resultSelector(jo, e);

                    return(r);
                }
Exemplo n.º 2
0
                public async Task <bool> MoveNext(CancellationToken cancellationToken)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    if (_sourceEnumerator == null)
                    {
                        _outerGroupJoinIncludeContext = _groupJoinAsyncEnumerable._outerGroupJoinInclude?.Initialize(_groupJoinAsyncEnumerable._queryContext);
                        _innerGroupJoinIncludeContext = _groupJoinAsyncEnumerable._innerGroupJoinInclude?.Initialize(_groupJoinAsyncEnumerable._queryContext);
                        _outerEntityAccessor          = _groupJoinAsyncEnumerable._outerGroupJoinInclude?.EntityAccessor as Func <TOuter, object>;
                        _innerEntityAccessor          = _groupJoinAsyncEnumerable._innerGroupJoinInclude?.EntityAccessor as Func <TInner, object>;
                        _sourceEnumerator             = _groupJoinAsyncEnumerable._source.GetEnumerator();
                        _hasNext = await _sourceEnumerator.MoveNext(cancellationToken);

                        _nextOuter = default(TOuter);
                    }

                    if (_hasNext)
                    {
                        var outer
                            = Equals(_nextOuter, default(TOuter))
                                ? _groupJoinAsyncEnumerable._outerShaper
                              .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current)
                                : _nextOuter;

                        _nextOuter = default(TOuter);

                        if (_outerGroupJoinIncludeContext != null)
                        {
                            if (_outerEntityAccessor != null)
                            {
                                await _outerGroupJoinIncludeContext.IncludeAsync(_outerEntityAccessor(outer), cancellationToken);
                            }
                            else
                            {
                                await _outerGroupJoinIncludeContext.IncludeAsync(outer, cancellationToken);
                            }
                        }

                        var inner
                            = _groupJoinAsyncEnumerable._innerShaper
                              .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current);

                        var inners = new List <TInner>();

                        if (inner == null)
                        {
                            Current
                                = _groupJoinAsyncEnumerable._resultSelector(
                                      outer, AsyncLinqOperatorProvider.ToAsyncEnumerable(inners));

                            _hasNext = await _sourceEnumerator.MoveNext(cancellationToken);

                            return(true);
                        }

                        var currentGroupKey = _groupJoinAsyncEnumerable._innerKeySelector(inner);

                        if (_innerGroupJoinIncludeContext != null)
                        {
                            if (_innerEntityAccessor != null)
                            {
                                await _innerGroupJoinIncludeContext.IncludeAsync(_innerEntityAccessor(inner), cancellationToken);
                            }
                            else
                            {
                                await _innerGroupJoinIncludeContext.IncludeAsync(inner, cancellationToken);
                            }
                        }

                        inners.Add(inner);

                        while (true)
                        {
                            _hasNext = await _sourceEnumerator.MoveNext(cancellationToken);

                            if (!_hasNext)
                            {
                                break;
                            }

                            if (_groupJoinAsyncEnumerable._hasOuters)
                            {
                                _nextOuter
                                    = _groupJoinAsyncEnumerable._outerShaper
                                      .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current);

                                if (!Equals(outer, _nextOuter))
                                {
                                    break;
                                }

                                _nextOuter = default(TOuter);
                            }

                            inner
                                = _groupJoinAsyncEnumerable._innerShaper
                                  .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current);

                            if (inner == null)
                            {
                                break;
                            }

                            var innerKey = _groupJoinAsyncEnumerable._innerKeySelector(inner);

                            if (!_comparer.Equals(currentGroupKey, innerKey))
                            {
                                break;
                            }

                            if (_innerGroupJoinIncludeContext != null)
                            {
                                await _innerGroupJoinIncludeContext.IncludeAsync(inner, cancellationToken);
                            }

                            inners.Add(inner);
                        }

                        Current
                            = _groupJoinAsyncEnumerable._resultSelector(
                                  outer, AsyncLinqOperatorProvider.ToAsyncEnumerable(inners));

                        return(true);
                    }

                    return(false);
                }
                public async Task <bool> MoveNext(CancellationToken cancellationToken)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    if (_sourceEnumerator == null)
                    {
                        _sourceEnumerator = _groupJoinAsyncEnumerable._source.GetEnumerator();
                        _hasNext          = await _sourceEnumerator.MoveNext(cancellationToken);

                        _nextOuter = default;
                    }

                    if (_hasNext)
                    {
                        var outer
#pragma warning disable IDE0034 // Simplify 'default' expression - Equals(object, object) causes default(object)
                            = Equals(_nextOuter, default(TOuter))
#pragma warning restore IDE0034 // Simplify 'default' expression
                                ? _groupJoinAsyncEnumerable._outerShaper
                              .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current)
                                : _nextOuter;

                        _nextOuter = default;

                        var inner
                            = _groupJoinAsyncEnumerable._innerShaper
                              .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current);

                        var inners = new List <TInner>();

                        if (inner == null)
                        {
                            Current
                                = _groupJoinAsyncEnumerable._resultSelector(
                                      outer, inners.ToAsyncEnumerable());

                            _hasNext = await _sourceEnumerator.MoveNext(cancellationToken);

                            return(true);
                        }

                        var currentGroupKey = _groupJoinAsyncEnumerable._innerKeySelector(inner);

                        inners.Add(inner);

                        while (true)
                        {
                            _hasNext = await _sourceEnumerator.MoveNext(cancellationToken);

                            if (!_hasNext)
                            {
                                break;
                            }

                            if (_groupJoinAsyncEnumerable._hasOuters)
                            {
                                _nextOuter
                                    = _groupJoinAsyncEnumerable._outerShaper
                                      .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current);

                                if (!Equals(outer, _nextOuter))
                                {
                                    break;
                                }

                                _nextOuter = default;
                            }

                            inner
                                = _groupJoinAsyncEnumerable._innerShaper
                                  .Shape(_groupJoinAsyncEnumerable._queryContext, _sourceEnumerator.Current);

                            if (inner == null)
                            {
                                break;
                            }

                            var innerKey = _groupJoinAsyncEnumerable._innerKeySelector(inner);

                            if (!_comparer.Equals(currentGroupKey, innerKey))
                            {
                                break;
                            }

                            inners.Add(inner);
                        }

                        Current
                            = _groupJoinAsyncEnumerable._resultSelector(
                                  outer, inners.ToAsyncEnumerable());

                        return(true);
                    }

                    return(false);
                }
Exemplo n.º 4
0
 .MakeGenericMethod(TOuter, TInner, TKey, TResult);
Exemplo n.º 5
0
 public Match(TOuter outer, TInner inner)
 {
     Outer = outer;
     Inner = inner;
 }
 public OuterEntry(TOuter outer, TKey key)
 {
     this.Key                    = key;
     this.MatchingInners         = new ContinuousCollection <TInner>();
     this.MatchingInnersReadOnly = this.MatchingInners.AsReadOnly();
 }
Exemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="o"></param>
 public void Foo(TOuter o)
 {
 }