Exemple #1
0
 public async Task Insert(T entity, string insertSql)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         await conn.ExecuteAsync(insertSql, entity);
     }
 }
Exemple #2
0
 public async Task <List <T> > SelectPara(string selectSql, object param = null)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         return(await Task.Run(() => conn.Query <T>(selectSql, param).ToList()));
     }
 }
Exemple #3
0
 /// <summary>
 /// 无参存储过程
 /// </summary>
 /// <param name="SPName"></param>
 /// <returns></returns>
 public async Task <List <T> > ExecQuerySP(string SPName)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         return(await Task.Run(() => conn.Query <T>(SPName, null, null, true, null, CommandType.StoredProcedure).ToList()));
     }
 }
Exemple #4
0
 public async Task Delete(int Id, string deleteSql)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         await conn.ExecuteAsync(deleteSql, new { Id = Id });
     }
 }
Exemple #5
0
 public async Task Update(T entity, string updateSql)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         await conn.ExecuteAsync(updateSql, entity);
     }
 }
Exemple #6
0
 public async Task <T> Select(int Id, string selectSql)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         //string selectSql = @"SELECT Id, UserName, Password, Gender, Birthday, CreateDate, IsDelete FROM dbo.Users";
         return(await Task.Run(() => conn.QuerySingle <T>(selectSql, new { Id = Id })));
     }
 }
Exemple #7
0
 public async Task <T> Detail(int Id, string detailSql)
 {
     using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
     {
         //string querySql = @"SELECT Id, UserName, Password, Gender, Birthday, CreateDate, IsDelete FROM dbo.Users WHERE Id=@Id";
         return(await conn.QueryFirstOrDefaultAsync <T>(detailSql, new { Id = Id }));
     }
 }
Exemple #8
0
        public async Task <Tuple <List <T>, int> > GetPageByProcList(string viewName, string fieldName = "*", string whereString = " 1=1", string orderString = "ID", int page = 1, int pageSize = 10)
        {
            int recordTotal = 0;

            using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
            {
                //conn.Open();
                DynamicParameters parm = new DynamicParameters();
                parm.Add("viewName", viewName);
                parm.Add("fieldName", fieldName);
                parm.Add("whereString", whereString);
                parm.Add("pageSize", pageSize);
                parm.Add("pageNo", page);
                parm.Add("orderString", orderString);
                parm.Add("recordTotal", 0, DbType.Int32, ParameterDirection.Output);

                var list = await Task.Run(() => conn.Query <T>("SIDE_PLM_ProcViewPager", parm, commandType : CommandType.StoredProcedure).ToList());

                recordTotal = parm.Get <int>("@recordTotal");//返回总页数

                //  conn.Close();
                return(new Tuple <List <T>, int>(list, recordTotal));
            }
        }