Ejemplo n.º 1
0
        /// <summary>
        /// Helper method to create and populate the result from the datareader
        /// </summary>
        /// <param name="dataReader"></param>
        /// <returns></returns>
        public static QueryResultStructure FromDataReader(IDataReader dataReader)
        {
            if (dataReader == null)
            {
                throw new ArgumentNullException(nameof(dataReader));
            }

            var result = new QueryResultStructure();

            for (var fieldIndex = 0; fieldIndex < dataReader.FieldCount; fieldIndex++)
            {
                result.AddColumn(dataReader.GetName(fieldIndex), fieldIndex);
            }

            return(result);
        }
        private QueryResultStructure CreateDummyStructure(IEnumerable <string> fieldNames)
        {
            QueryResultStructure structure = new QueryResultStructure();

            fieldNames.Select((field, index) =>
            {
                return(new
                {
                    Field = field,
                    Index = index
                });
            }).ToList().ForEach(item =>
            {
                structure.AddColumn(item.Field, item.Index);
            });


            return(structure);
        }