Пример #1
0
        /// <summary>
        /// 用户自定义sql语句批量执行(非查询语句)
        /// </summary>
        /// <param name="sql">非查询sql语句集合</param>
        /// <returns>是否成功</returns>
        public static bool Excute(List <String> sqls)
        {
            DbConnection conn = SQLFactory.CreateDBConnection();

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            DbTransaction tran = conn.BeginTransaction();

            try
            {
                foreach (String sql in sqls)
                {
                    SQLFactory.CreateDBHelper().ExecuteNonQuery(tran, System.Data.CommandType.Text, sql, null);
                }

                tran.Commit();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 用户自定义sql语句查询
        /// </summary>
        /// <param name="sql">查询语句</param>
        /// <param name="parms">查询参数列表</param>
        /// <returns>查询对象集合</returns>
        public static List <T> QueryEx(String sql, List <DbParameter> parms = null)
        {
            DataTable dt       = SQLFactory.CreateDBHelper().Query(sql, parms);
            List <T>  entities = NDolls.Data.Util.DataConvert <T> .ToEntities(dt);

            return(entities);
        }
Пример #3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public DBTransaction()
 {
     this.dbHelper = SQLFactory.CreateDBHelper();
 }
Пример #4
0
 /// <summary>
 /// 用户自定义sql语句执行(非查询语句)
 /// </summary>
 /// <param name="sql">非查询sql语句</param>
 /// <returns>执行成功的数据行数</returns>
 public static int Excute(String sql)
 {
     return(SQLFactory.CreateDBHelper().ExecuteNonQuery(System.Data.CommandType.Text, sql, null));
 }
Пример #5
0
 /// <summary>
 /// 用户自定义sql语句查询
 /// </summary>
 /// <param name="sql">查询语句</param>
 /// <param name="parms">查询参数列表</param>
 /// <returns>查询结果集</returns>
 public static DataTable Query(String sql, List <DbParameter> parms = null)
 {
     return(SQLFactory.CreateDBHelper().Query(sql, parms));
 }
Пример #6
0
 /// <summary>
 /// 用户自定义sql语句查询(返回一行一列)
 /// </summary>
 /// <param name="sql">查询sql语句</param>
 /// <returns>查询结果</returns>
 public static object Single(String sql, List <DbParameter> parms = null)
 {
     return(SQLFactory.CreateDBHelper().ExecuteScalar(System.Data.CommandType.Text, sql, parms));
 }