/// <summary> /// 根据模型更新 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>是否成功</returns> public bool Update(Colorinfo model, IDbConnection connection = null, IDbTransaction transaction = null) { var update = new LambdaUpdate <Colorinfo>(); if (!model.Id.IsNullOrEmpty()) { update.Where(p => p.Id == model.Id); } if (!model.StandardColor.IsNullOrEmpty()) { update.Set(p => p.StandardColor == model.StandardColor); } if (!model.ChinaDescribe.IsNullOrEmpty()) { update.Set(p => p.ChinaDescribe == model.ChinaDescribe); } if (!model.EngDescibe.IsNullOrEmpty()) { update.Set(p => p.EngDescibe == model.EngDescibe); } if (!model.ParentId.IsNullOrEmpty()) { update.Set(p => p.ParentId == model.ParentId); } if (!model.HtmlCode.IsNullOrEmpty()) { update.Set(p => p.HtmlCode == model.HtmlCode); } if (!model.IsDelete.IsNullOrEmpty()) { update.Set(p => p.IsDelete == model.IsDelete); } return(update.GetUpdateResult(connection, transaction)); }
/// <summary> /// 根据模型插入 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>是否成功</returns> public int InsertReturnKey(Colorinfo model, IDbConnection connection = null, IDbTransaction transaction = null) { var insert = new LambdaInsert <Colorinfo>(); if (!model.StandardColor.IsNullOrEmpty()) { insert.Insert(p => p.StandardColor == model.StandardColor); } if (!model.ChinaDescribe.IsNullOrEmpty()) { insert.Insert(p => p.ChinaDescribe == model.ChinaDescribe); } if (!model.EngDescibe.IsNullOrEmpty()) { insert.Insert(p => p.EngDescibe == model.EngDescibe); } if (!model.ParentId.IsNullOrEmpty()) { insert.Insert(p => p.ParentId == model.ParentId); } if (!model.HtmlCode.IsNullOrEmpty()) { insert.Insert(p => p.HtmlCode == model.HtmlCode); } if (!model.IsDelete.IsNullOrEmpty()) { insert.Insert(p => p.IsDelete == model.IsDelete); } return(insert.GetInsertResult(connection, transaction)); }
public ColorRes(Colorinfo colorinfo) { //颜色Id Id = colorinfo.Id; //中文描述 ChinaDescribe = colorinfo.ChinaDescribe; //标准色号 StandardColor = colorinfo.StandardColor; //英文描述 EngDescibe = colorinfo.EngDescibe; //颜色代码 HtmlCode = colorinfo.HtmlCode; }
/// <summary> /// 数据条数 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>对象列表</returns> public int SelectCount(Colorinfo model = null, IDbConnection connection = null, IDbTransaction transaction = null) { var query = new LambdaQuery <Colorinfo>(); if (model != null) { if (!model.Id.IsNullOrEmpty()) { query.Where(p => p.Id == model.Id); } if (!model.StandardColor.IsNullOrEmpty()) { query.Where(p => p.StandardColor == model.StandardColor); } if (!model.ChinaDescribe.IsNullOrEmpty()) { query.Where(p => p.ChinaDescribe == model.ChinaDescribe); } if (!model.EngDescibe.IsNullOrEmpty()) { query.Where(p => p.EngDescibe == model.EngDescibe); } if (!model.ParentId.IsNullOrEmpty()) { query.Where(p => p.ParentId == model.ParentId); } if (!model.HtmlCode.IsNullOrEmpty()) { query.Where(p => p.HtmlCode == model.HtmlCode); } if (!model.IsDelete.IsNullOrEmpty()) { query.Where(p => p.IsDelete == model.IsDelete); } } return(query.GetQueryCount(connection, transaction)); }
/// <summary> /// 数据条数 /// </summary> /// <param name="model">模型</param> /// <returns>对象列表</returns> public int SelectCount(Colorinfo model) { return(ColorinfoOper.Instance.SelectCount(model)); }
/// <summary> /// 筛选全部数据 /// </summary> /// <param name="model">模型</param> /// <returns>对象列表</returns> public List <Colorinfo> SelectByModel(Colorinfo model) { return(ColorinfoOper.Instance.SelectAll(model)); }
/// <summary> /// 根据模型插入 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public int InsertReturnKey(Colorinfo model) { return(ColorinfoOper.Instance.InsertReturnKey(model)); }
/// <summary> /// 根据模型插入 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public bool Insert(Colorinfo model) { return(ColorinfoOper.Instance.Insert(model)); }
/// <summary> /// 根据模型更新 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public bool Update(Colorinfo model) { return(ColorinfoOper.Instance.Update(model)); }
/// <summary> /// 根据模型删除数据 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public bool DeleteModel(Colorinfo model) { return(ColorinfoOper.Instance.DeleteModel(model)); }
/// <summary> /// 根据分页筛选数据 /// </summary> /// <param name="Key">主键</param> /// <param name="start">开始数据</param> /// <param name="PageSize">页面长度</param> /// <param name="desc">排序</param> /// <param name="model">对象</param> /// <returns>对象列表</returns> public List <Colorinfo> SelectByPage(string Key, int start, int PageSize, bool desc, Colorinfo model, string SelectFiled) { return(ColorinfoOper.Instance.SelectByPage(Key, start, PageSize, desc, model)); }
/// <summary> /// 根据分页筛选数据 /// </summary> /// <param name="Key">主键</param> /// <param name="start">开始数据</param> /// <param name="PageSize">页面长度</param> /// <param name="desc">排序</param> /// <param name="model">对象</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>对象列表</returns> public List <Colorinfo> SelectByPage(string Key, int start, int PageSize, bool desc = true, Colorinfo model = null, string SelectFiled = null, IDbConnection connection = null, IDbTransaction transaction = null) { var query = new LambdaQuery <Colorinfo>(); if (model != null) { if (!model.Id.IsNullOrEmpty()) { query.Where(p => p.Id == model.Id); } if (!model.StandardColor.IsNullOrEmpty()) { query.Where(p => p.StandardColor == model.StandardColor); } if (!model.ChinaDescribe.IsNullOrEmpty()) { query.Where(p => p.ChinaDescribe == model.ChinaDescribe); } if (!model.EngDescibe.IsNullOrEmpty()) { query.Where(p => p.EngDescibe == model.EngDescibe); } if (!model.ParentId.IsNullOrEmpty()) { query.Where(p => p.ParentId == model.ParentId); } if (!model.HtmlCode.IsNullOrEmpty()) { query.Where(p => p.HtmlCode == model.HtmlCode); } if (!model.IsDelete.IsNullOrEmpty()) { query.Where(p => p.IsDelete == model.IsDelete); } } if (SelectFiled != null) { SelectFiled = SelectFiled.ToLowerInvariant(); if (SelectFiled.Contains("id,")) { query.Select(p => new { p.Id }); } if (SelectFiled.Contains("standardcolor,")) { query.Select(p => new { p.StandardColor }); } if (SelectFiled.Contains("chinadescribe,")) { query.Select(p => new { p.ChinaDescribe }); } if (SelectFiled.Contains("engdescibe,")) { query.Select(p => new { p.EngDescibe }); } if (SelectFiled.Contains("parentid,")) { query.Select(p => new { p.ParentId }); } if (SelectFiled.Contains("htmlcode,")) { query.Select(p => new { p.HtmlCode }); } if (SelectFiled.Contains("isdelete,")) { query.Select(p => new { p.IsDelete }); } } if (Key != null) { query.OrderByKey(Key, desc); } return(query.GetQueryPageList(start, PageSize, connection, transaction)); }