예제 #1
0
        protected override int DoInsertMultiple <T>(SqlConnection conn, IDbTransaction tran, IList <T> t)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var item in t)
            {
                sb.Append(DBSqlHelper.GetInsertSQL(item));
            }

            //考虑到有的时候批量插入需要按照顺序来插入,所以这个地方暂时不用并行运算了
            //Parallel.ForEach(t, item =>
            //{
            //    sb.Append(DBSqlHelper.GetInsertSQL(item));
            //});

            int row = conn.Execute(sb.ToString(), null, tran, null, CommandType.Text);

            if (row > 0)
            {
                tran.Commit();
            }
            else
            {
                tran.Rollback();
            }

            return(row);
        }
예제 #2
0
        protected override int DoUpdateSingle <T>(SqlConnection conn, T t, string where)
        {
            string sql = DBSqlHelper.GetUpdateSQL <T>(t, where);

            return(conn.Execute(sql));
        }
예제 #3
0
        protected override int DoInsertSingle <T>(SqlConnection conn, T t)
        {
            string sql = DBSqlHelper.GetInsertSQL <T>(t);

            return(conn.Execute(sql));
        }