Esempio n. 1
0
        /// <summary>
        /// Create a collection of target objects from a source data reader
        /// </summary>
        /// <remarks>
        /// Creates a target list and populates it from the source reader - reading from the reader for each
        /// new target object. Can be called with a data reader which has not already been positioned
        /// </remarks>
        /// <param name="source"></param>
        /// <returns></returns>
        public static List <TTarget> CreateTargetList(IDataReader source)
        {
            var map  = new DataReaderAutoMap <TTarget>();
            var list = new List <TTarget>();

            while (source.Read())
            {
                list.Add(CreateTarget(source));
            }
            return(list);
        }
Esempio n. 2
0
        /// <summary>
        /// Populate an existing target object from a source data reader, positioned at the correct row
        /// </summary>
        /// <remarks>
        /// Does not read from the data reader, so the reader needs to have been positioned first
        /// </remarks>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void PopulateTarget(IDataReader source, TTarget target)
        {
            var map = new DataReaderAutoMap <TTarget>();

            map.Populate(source, target);
        }
Esempio n. 3
0
        /// <summary>
        /// Create a target object from a source data reader, positioned at the correct row
        /// </summary>
        /// <remarks>
        /// Does not read from the data reader, so the reader needs to have been positioned first
        /// </remarks>
        /// <param name="source"></param>
        /// <returns></returns>
        public static TTarget CreateTarget(IDataReader source)
        {
            var map = new DataReaderAutoMap <TTarget>();

            return(map.Create(source));
        }