protected override IStream <TOut> CreateOutputStream(EfCoreLookupArgs <TIn, TValue, TEntity, TValueOut, TKey, TOut> args) { IPushObservable <TOut> matchingS = args.SourceStream.Observable.Map(elt => { var matcher = this.ExecutionContext.ContextBag.Resolve(this.NodeName, () => { var ctx = args.KeyedConnection == null ? this.ExecutionContext.DependencyResolver.Resolve <DbContext>() : this.ExecutionContext.DependencyResolver.Resolve <DbContext>(args.KeyedConnection); return(this.ExecutionContext.InvokeInDedicatedThreadAsync(ctx, () => new EfMatcher <TValue, TEntity, TKey>(new EfMatcherConfig <TValue, TEntity, TKey> { Context = ctx, CreateIfNotFound = args.CreateIfNotFound, LeftKeyExpression = args.GetLeftStreamKey, RightKeyExpression = args.GetEntityStreamKey, MinCacheSize = args.CacheSize, GetFullDataset = args.GetFullDataset, Query = args.Query(new DbContextWrapper(ctx)) })).Result); }); TEntity entity = default; var val = args.GetInputValue(elt); if (!args.GetFullDataset) { entity = this.ExecutionContext.InvokeInDedicatedThreadAsync(matcher.Context, () => matcher.GetMatch(val)).Result; } else { entity = matcher.GetMatch(val); } return(args.GetOutputValue(elt, args.ResultSelector(val, entity))); } ); return(base.CreateUnsortedStream(matchingS)); }
public EfCoreLookupStreamNode(string name, EfCoreLookupArgs <TIn, TValue, TEntity, TValueOut, TKey, TOut> args) : base(name, args) { }