标签:min ring 查询 new password use list OLE region
#region 助手类
public class Dbhelper
{
static string sqlConnectionString = @"Database=CMS;Server=42.159.145.218,1401;User ID =azureadmin; Password =P@ss1234567890;";
//新增
public object Insert<T>(string sql, T t)
{
try
{
object result;
using (IDbConnection connection = new SqlConnection(sqlConnectionString))
{
result = connection.Execute(sql, t);
}
return result;
}
catch (Exception ex)
{
Console.Write(ex.Message);
return -999;
}
}
public object BatchInsert<T>(string sql, List<T> list)
{
try
{
object result;
using (IDbConnection connection = new SqlConnection(sqlConnectionString))
{
result = connection.Execute(sql, list);
}
return result;
}
catch (Exception ex)
{
Console.Write(ex.Message);
return -999;
}
}
//删除
public int Delete<T>(string sql, T t)
{
try
{
int result;
using (IDbConnection connection = new SqlConnection(sqlConnectionString))
{
result = connection.Execute(sql, t);
}
return result;
}
catch
{
return -999;
}
}
//查询
public object Search<T>(string sql, T t)
{
try
{
object result;
using (IDbConnection connection = new SqlConnection(sqlConnectionString))
{
result = connection.Execute(sql, t);
}
return result;
}
catch (Exception ex)
{
return ex.Message;
}
}
//修改
public int Update<T>(string sql, T t)
{
try
{
int result;
using (IDbConnection connection = new SqlConnection(sqlConnectionString))
{
result = connection.Execute(sql, t);
}
return result;
}
catch
{
return -999;
}
}
//查询
public List<T> SearchData<T>(string sql, object obj)
{
IDbConnection connection = new SqlConnection(sqlConnectionString);
return connection.Query<T>(sql, obj).ToList();
}
}
#endregion
标签:min ring 查询 new password use list OLE region
原文地址:https://www.cnblogs.com/ning-xiaowo/p/12186471.html