using System;
using System.Collections.Generic;
using System.Linq;
namespace Mtxfw.Utility.DataAccess
{
///
/// 执行SQL或者存储过程类
///
public partial class Sql : DbHelperSqlSugar
{
///
/// 执行Sql语句和存储过程
///
///
///
///
///
public T SqlQuery(string sqlStr, object obj) where T : class, new()
{
return Db.Ado.SqlQuery(sqlStr, obj).SingleOrDefault();
}
///
/// 执行sql语句返回List
///
///
///
///
///
public List SqlQueryList(string sqlStr, object obj) where T : class, new()
{
return Db.Ado.SqlQuery(sqlStr, obj);
}
///
/// 执行事务
///
///
///
///
///
public List SqlQueryTran(string sqlStr, object obj) where T : class, new()
{
var result = Db.Ado.UseTran>(() =>
{
return Db.Ado.SqlQuery(sqlStr, obj);
throw new Exception("error haha");
});
return null;
}
///
/// 执行事务
///
///
///
///
public int SqlQueryTran(string sqlStr)
{
var result = Db.Ado.UseTran(() =>
{
return Db.Ado.ExecuteCommand(sqlStr);
throw new Exception("error haha");
});
return 0;
}
///
/// 执行事务
///
///
///
///
public int SqlQueryTran(string sqlStr, object param)
{
var result = Db.Ado.UseTran(() =>
{
return Db.Ado.ExecuteCommand(sqlStr, param);
throw new Exception("error haha");
});
return 0;
}
}
}