コード例 #1
0
        public List <T> ExecuteList <T>(IDbTransaction p_transaction, string p_sqlWhere)
            where T : new()
        {
            TableInformation t_tableInformation = this.GetTableInformations(typeof(T));
            SqlCommandHelper t_sqlHelper        = new SqlCommandHelper(m_providerConfiguration, t_tableInformation);

            string t_sql = t_sqlHelper.CreateSelectByWhere(p_sqlWhere);

            IDbCommand cmd = p_transaction.Connection.CreateCommand();

            cmd.Transaction = p_transaction;
            cmd.CommandText = t_sql;

            IDataReader t_reader = cmd.ExecuteReader();

            try
            {
                List <T> t_results = new List <T>();
                while (t_reader.Read())
                {
                    T t_genericObject = new T();

                    this.PopulateEntity(t_reader, t_tableInformation, t_genericObject);

                    t_results.Add(t_genericObject);
                }

                return(t_results);
            }
            finally
            {
                t_reader.Close();
            }
        }
コード例 #2
0
        public T FindBySQL <T>(IDbTransaction p_transaction, string p_sqlWhere)
            where T : new()
        {
            TableInformation t_tableInformation = this.GetTableInformations(typeof(T));
            SqlCommandHelper t_sqlHelper        = new SqlCommandHelper(m_providerConfiguration, t_tableInformation);

            string t_sql = t_sqlHelper.CreateSelectByWhere(p_sqlWhere);

            IDbCommand cmd = p_transaction.Connection.CreateCommand();

            cmd.Transaction = p_transaction;
            cmd.CommandText = t_sql;

            IDataReader t_reader        = cmd.ExecuteReader();
            T           t_genericObject = default(T);

            t_genericObject = new T();

            if (t_reader.Read())
            {
                this.PopulateEntity(t_reader, t_tableInformation, t_genericObject);
            }

            t_reader.Close();

            return(t_genericObject);
        }