//模板信息:{"Template":{"Language":"C#"}} //输出信息:{"Extension":".cs","FileName":"DAL\\CM\\LastPattleNumDAL"} using System; using System.Text; using System.Linq; using System.Collections.Generic; using LeadDataBaseUtility; namespace CleanMachine.DAL.CM { /// /// /// public class LastPattleNumDAL { public LastPattleNumDAL() { } #region 一般方法 /// /// 存在 /// public bool Exists(string Key) { string strSql = @"SELECT count(1) from CM_LastPattleNum WHERE Key=@Key "; return LeadDbHelperSQLite.ExecuteScalar(strSql, new { Key }) > 0; } /// /// 添加一个数据 /// public bool Add(CleanMachine.Model.CM.LastPattleNum model) { string strSql = $@"INSERT INTO CM_LastPattleNum (Key,Value) values (@Key,@Value) "; return LeadDbHelperSQLite.Execute(strSql, model) > 0; } /// /// 更新一个数据 /// public bool Update(CleanMachine.Model.CM.LastPattleNum model) { string strSql = $@"UPDATE CM_LastPattleNum SET Value=@Value WHERE Key=@Key "; return LeadDbHelperSQLite.Execute(strSql, model) > 0; } /// /// 删除一个数据 /// public bool Delete(string strWhere, object Params = null) { string strSql = $@"DELETE FROM CM_LastPattleNum "; if (strWhere.Trim() != "") { strSql += $" WHERE {strWhere}"; } return LeadDbHelperSQLite.Execute(strSql, Params) > 0; } /// /// 删除一个数据 /// public bool Delete(string Key) { return this.Delete("Key=@Key ", new { Key }) ; } /// /// 获得数据列表 /// public IEnumerable GetList(string strWhere, object Params = null) { string strSql = $@"SELECT * FROM CM_LastPattleNum "; if (strWhere.Trim() != "") { strSql += $" WHERE {strWhere}"; } return LeadDbHelperSQLite.Query(strSql, Params); } /// /// 获取一个对象 /// public CleanMachine.Model.CM.LastPattleNum GetModel(string Key) { return this.GetList("Key=@Key", new { Key }).FirstOrDefault(); } #endregion /// /// 删除一个数据 /// public bool Delete(string Key) { return this.Delete("Key=@Key ", new { Key }) ; } /// /// 获取一个对象 /// public CleanMachine.Model.CM.LastPattleNum GetModel(string Key) { return this.GetList("Key=@Key", new { Key }).QueryFirstOrDefault(); } /// /// 存在 /// public bool Exists(string Key) { string strSql = @"SELECT count(1) from CM_LastPattleNum WHERE Key=@Key "; return LeadDbHelperSQLite.ExecuteScalar(strSql, new { Key }) > 0; } /// /// 查询数据 /// // public IEnumerable GetModelList(RuleGroup rule) // { // var tuper = _dbhelper.BuildRuleGroupStr(rule); // return this.GetList(tuper.where, tuper.Param); // } } }