Пример #1
0
        public async Task FillAsync(Dictionary <LookupToken, IEnumerable> lookups, IRetriever retriever, CancellationToken token)
        {
            using (HeavyProfiler.Log("SQL", () => Command.Sql))
                using (DbDataReader reader = await Executor.UnsafeExecuteDataReaderAsync(Command, token: token))
                {
                    ProjectionRowEnumerator <KeyValuePair <K, V> > enumerator = new ProjectionRowEnumerator <KeyValuePair <K, V> >(reader, ProjectorExpression, lookups, retriever, token);

                    IEnumerable <KeyValuePair <K, V> > enumerabe = new ProjectionRowEnumerable <KeyValuePair <K, V> >(enumerator);

                    try
                    {
                        var lookUp = enumerabe.ToLookup(a => a.Key, a => a.Value);

                        lookups.Add(Token, lookUp);
                    }
                    catch (Exception ex) when(!(ex is OperationCanceledException))
                    {
                        FieldReaderException fieldEx = enumerator.Reader.CreateFieldReaderException(ex);

                        fieldEx.Command   = Command;
                        fieldEx.Row       = enumerator.Row;
                        fieldEx.Projector = ProjectorExpression;
                        throw fieldEx;
                    }
                }
        }
Пример #2
0
        public void Fill(Dictionary <LookupToken, IEnumerable> lookups, IRetriever retriever)
        {
            using (HeavyProfiler.Log("SQL", () => Command.Sql))
                using (DbDataReader reader = Executor.UnsafeExecuteDataReader(Command))
                {
                    ProjectionRowEnumerator <KeyValuePair <K, V> > enumerator = new ProjectionRowEnumerator <KeyValuePair <K, V> >(reader, ProjectorExpression, lookups, retriever);

                    IEnumerable <KeyValuePair <K, V> > enumerabe = new ProjectionRowEnumerable <KeyValuePair <K, V> >(enumerator);

                    try
                    {
                        var lookUp = enumerabe.ToLookup(a => a.Key, a => a.Value);

                        lookups.Add(Token, lookUp);
                    }
                    catch (Exception ex)
                    {
                        FieldReaderException fieldEx = enumerator.Reader.CreateFieldReaderException(ex);
                        fieldEx.Command   = Command;
                        fieldEx.Row       = enumerator.Row;
                        fieldEx.Projector = ProjectorExpression;
                        throw fieldEx;
                    }
                }
        }
Пример #3
0
        public async Task FillAsync(Dictionary <LookupToken, IEnumerable> lookups, IRetriever retriever, CancellationToken token)
        {
            Dictionary <K, MList <V> > requests = (Dictionary <K, MList <V> >)lookups.TryGetC(Token);

            if (requests == null)
            {
                return;
            }

            using (HeavyProfiler.Log("SQL", () => Command.Sql))
                using (DbDataReader reader = await Executor.UnsafeExecuteDataReaderAsync(Command, token: token))
                {
                    ProjectionRowEnumerator <KeyValuePair <K, MList <V> .RowIdElement> > enumerator = new ProjectionRowEnumerator <KeyValuePair <K, MList <V> .RowIdElement> >(reader, ProjectorExpression, lookups, retriever, token);

                    IEnumerable <KeyValuePair <K, MList <V> .RowIdElement> > enumerabe = new ProjectionRowEnumerable <KeyValuePair <K, MList <V> .RowIdElement> >(enumerator);

                    try
                    {
                        var lookUp = enumerabe.ToLookup(a => a.Key, a => a.Value);
                        foreach (var kvp in requests)
                        {
                            var results = lookUp[kvp.Key];

                            ((IMListPrivate <V>)kvp.Value).InnerList.AddRange(results);
                            ((IMListPrivate <V>)kvp.Value).InnerListModified(results.Select(a => a.Element).ToList(), null);
                            retriever.ModifiablePostRetrieving(kvp.Value);
                        }
                    }
                    catch (Exception ex) when(!(ex is OperationCanceledException))
                    {
                        FieldReaderException fieldEx = enumerator.Reader.CreateFieldReaderException(ex);

                        fieldEx.Command   = Command;
                        fieldEx.Row       = enumerator.Row;
                        fieldEx.Projector = ProjectorExpression;
                        throw fieldEx;
                    }
                }
        }