コード例 #1
0
        public static List <T> ToListByEmit <T>(this IDataReader dr, bool autoClose = true)
        {
            try
            {
                if (autoClose)
                {
                    using (dr)
                    {
                        List <T> list = EmitConverter.ReaderToEnumerable <T>(dr).ToList();

                        return(list);
                    }
                }
                else
                {
                    List <T> list = EmitConverter.ReaderToEnumerable <T>(dr).ToList();

                    return(list);
                }
            }
            catch (Exception ex)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                throw new PureDataException("DataReaderExtensions", ex);
            }
        }
コード例 #2
0
        public static T ToModelByEmit <T>(this IDataReader dr, bool autoClose = true)
        {
            try
            {
                if (autoClose)
                {
                    using (dr)
                    {
                        var result = EmitConverter.ReaderToModel <T>(dr);

                        return(result);
                    }
                }
                else
                {
                    var result = EmitConverter.ReaderToModel <T>(dr);

                    return(result);
                }


                return(default(T));
            }
            catch (Exception ex)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                throw new PureDataException("DataReaderExtensions", ex);
            }
        }