public EfCoreSaveArgsBuilder(IStream <TIn> sourceStream, Func <TIn, TInEf> getEntity, Func <TIn, TInEf, TOut> getOutput)
 {
     this.Args = new EfCoreSaveArgs <TInEf, TIn, TOut>
     {
         SourceStream = sourceStream,
         GetEntity    = getEntity,
         GetOutput    = getOutput
     };
 }
 public EfCoreSaveCorrelatedArgsBuilder(IStream <Correlated <TIn> > sourceStream, Func <TIn, TInEf> getEntity, Func <TIn, TInEf, TOut> getOutput)
 {
     this.Args = new EfCoreSaveArgs <TInEf, Correlated <TIn>, Correlated <TOut> >
     {
         SourceStream = sourceStream,
         GetEntity    = i => getEntity(i.Row),
         GetOutput    = (i, e) => new Correlated <TOut> {
             Row = getOutput(i.Row, e), CorrelationKeys = i.CorrelationKeys
         }
     };
 }
        protected override IStream <TOut> CreateOutputStream(EfCoreSaveArgs <TInEf, TIn, TOut> args)
        {
            var ret = args.SourceStream.Observable
                      .Chunk(args.BatchSize)
                      .Map(i => i.Select(j => (Input: j, Entity: args.GetEntity(j))).ToList())
                      .Do(i =>
            {
                var dbContext = args.KeyedConnection == null
                        ? this.ExecutionContext.DependencyResolver.Resolve <DbContext>()
                        : this.ExecutionContext.DependencyResolver.Resolve <DbContext>(args.KeyedConnection);
                this.ExecutionContext.InvokeInDedicatedThreadAsync(dbContext, () => ProcessBatch(i, dbContext, args.BulkLoadMode)).Wait();
            })
                      .FlatMap((i, ct) => PushObservable.FromEnumerable(i, ct))
                      .Map(i => args.GetOutput(i.Input, i.Entity));

            return(base.CreateUnsortedStream(ret));
        }
 private EfCoreSaveArgsBuilder(EfCoreSaveArgs <TInEf, TIn, TOut> args)
 {
     this.Args = args;
 }
 public EfCoreSaveStreamNode(string name, EfCoreSaveArgs <TInEf, TIn, TOut> args) : base(name, args)
 {
 }
 private EfCoreSaveCorrelatedArgsBuilder(EfCoreSaveArgs <TInEf, Correlated <TIn>, Correlated <TOut> > args)
 {
     this.Args = args;
 }