public static T FirstOrDefault <T>(string sql, params object[] args) { using (var db = new PetaDbContext()) { return(db.FirstOrDefault <T>(sql, args)); } }
public static List <T> Fetch <T>(long page, long itemsPerPage, string sql, params object[] args) { using (var db = new PetaDbContext()) { return(db.Fetch <T>(page, itemsPerPage, sql, args)); } }
public int Delete(object id) { using (var db = new PetaDbContext()) { return(db.Delete <T>(id)); } }
public static List <T> Fetch <T>(string sql, params object[] args) { using (var db = new PetaDbContext()) { return(db.Fetch <T>(sql, args)); } }
public static IEnumerable <T> Query <T>(string sql, params object[] args) { using (var db = new PetaDbContext()) { return(db.Query <T>(sql, args)); } }
/// <summary> /// Remark:获取IEnumerable列表系列重载方法 /// </summary> #region 获取列表系列重载方法 public static IEnumerable <T> Query <T>(Sql sql) { using (var db = new PetaDbContext()) { return(db.Query <T>(sql)); } }
public static T SingleOrDefault <T>(object primaryKey) { using (var db = new PetaDbContext()) { return(db.SingleOrDefault <T>(primaryKey)); } }
public bool IsExists <T>(object id) where T : class { using (var db = new PetaDbContext()) { return(db.Exists <T>(id)); } }
public int Delete <T>(object id) where T : class { using (var db = new PetaDbContext()) { return(db.Delete <T>(id)); } }
/// <summary> /// Remark:插入对象实体系列重载方法 /// </summary> #region 数据新增方法 public static object Insert(object obj) { using (var db = new PetaDbContext()) { return(db.Insert(obj)); } }
/// <summary> /// Remark:执行单条sql /// </summary> #region 执行单条方法 public static int Execute(Sql sql) { using (var db = new PetaDbContext()) { return(db.Execute(sql)); } }
public static List <T> Fetch <T>(Sql sql) { using (var db = new PetaDbContext()) { return(db.Fetch <T>(sql)); } }
public static int Execute(string sql, params object[] args) { using (var db = new PetaDbContext()) { return(db.Execute(sql, args)); } }
public static object Update(string tableName, string primaryKey, bool autoIncrement, object obj) { using (var db = new PetaDbContext()) { return(db.Update(tableName, primaryKey, obj)); } }
/// <summary> /// Remark:删除对象实体系列重载方法 /// </summary> #region 数据删除方法 public static int Delete(object obj) { using (var db = new PetaDbContext()) { return(db.Delete(obj)); } }
public static object Insert(string tableName, string primaryKeyName, bool autoIncrement, object obj) { using (var db = new PetaDbContext()) { return(db.Insert(tableName, primaryKeyName, obj)); } }
public bool IsExists <T>(string sqlWhere, params object[] args) where T : class { using (var db = new PetaDbContext()) { return(db.Exists <T>(sqlWhere, args)); } }
public List <T> Fetch <T>(long page, long itemsPerPage, Sql sql) { using (var db = new PetaDbContext()) { return(db.Fetch <T>(page, itemsPerPage, sql)); } }
/// <summary> /// Remark:获取对象实体系列重载方法 /// </summary> #region 获取对象实体系列重载方法 public static T FirstOrDefault <T>(Sql sql) { using (var db = new PetaDbContext()) { return(db.FirstOrDefault <T>(sql)); } }
public int LogicDelete <T>(T entity) where T : class { using (var db = new PetaDbContext()) { return(db.Update(entity, new List <string> { "recordstatus" })); } }
/// <summary> /// Remark:获取List列表系列重载方法 /// </summary> #region 获取分页系列重载方法 public static List <T> PageList <T>(int page, int pageSize, string sql, out int recordCount) { int pageIndex = page; using (var db = new PetaDbContext()) { var result = db.Page <T>(pageIndex, pageSize, sql); recordCount = (int)result.TotalItems; return(result.Items); } }
public static List <T> PageList <T>(int page, int pageSize, string sql, out int recordCount, params object[] args) { int pageIndex = page; using (var db = new PetaDbContext()) { //PetaPoco框架自带分页 var result = db.Page <T>(pageIndex, pageSize, sql, args); recordCount = (int)result.TotalItems; return(result.Items); } }
public bool Insert(List <T> entities) { using (var db = new PetaDbContext()) { try { db.BeginTransaction(); foreach (var item in entities) { db.Insert(item); } db.CompleteTransaction(); } catch { db.AbortTransaction(); throw; } } return(true); }
public bool Insert <T>(List <T> entities) where T : class { using (var db = new PetaDbContext()) { try { db.BeginTransaction(); foreach (var entity in entities) { db.Insert(entity); } db.CompleteTransaction(); } catch { db.AbortTransaction(); throw; } } return(true); }