public static bool TryReadTo(DbDataReader dbDataReader, IDataWriter <int> dataWriter)
        {
            if (dataWriter is IArrayCollectionRW acrw)
            {
                var invoker = new FastObjectArrayCollectionInvoker(dbDataReader, dataWriter);

                acrw.InvokeElementType(invoker);

                return(invoker.Result);
            }

            return(false);
        }
Пример #2
0
        public override void ReadArray(IDataWriter <int> valueWriter)
        {
            switch (state)
            {
            case ReadState.Table:

                state = ReadState.Row;

                if (!FastObjectArrayCollectionInvoker.TryReadTo(dbDataReader, valueWriter))
                {
                    valueWriter.Initialize();

                    for (int i = 0; dbDataReader.Read(); i++)
                    {
                        valueWriter.OnWriteValue(i, this);
                    }
                }

                state = ReadState.Finish;

                break;

            case ReadState.Row:
                state = ReadState.Value;

                valueWriter.Initialize();

                for (ordinal = 0; ordinal < dbDataReader.FieldCount; ordinal++)
                {
                    valueWriter.OnWriteValue(ordinal, this);
                }

                state = ReadState.Row;

                break;

            case ReadState.Value:
                base.ReadArray(valueWriter);

                break;

            default:
                if (dbDataReader.NextResult())
                {
                    goto case ReadState.Table;
                }

                throw new ArgumentException("Finish");
            }
        }