Exemplo n.º 1
0
        public async Task InnerInsert(IEnumerable <TSource> source, IContextAdapter contextAdapter)
        {
            if (source == null)
            {
                return;
            }

            var extractor = _extractor.Compile();
            var s         = source.Where(o => extractor(o) != null).ToArray();

            if (!s.Any())
            {
                return;
            }

            var copy = GetCopyPk(contextAdapter);

            foreach (var parent in s)
            {
                foreach (var child in extractor(parent))
                {
                    copy.Invoke(parent, child);
                }
            }

            await contextAdapter.BulkInsertCascade(s.SelectMany(extractor).Distinct().ToArray(), _cascades);
        }
        public async Task InnerInsert(IEnumerable <TSource> source, IContextAdapter contextAdapter)
        {
            if (source == null)
            {
                return;
            }

            var extractor = _extractor.Compile();
            var s         = source.Where(o => extractor(o) != null).ToArray();

            if (!s.Any())
            {
                return;
            }

            var copyPk       = GetCopyPk(contextAdapter);
            var destinations = s.Select(extractor).Distinct().ToArray();
            await contextAdapter.BulkInsertCascade(destinations, _cascades);

            foreach (var destination in s)
            {
                copyPk(destination, destination);
            }
        }