/// <summary> /// 根据模型插入 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>是否成功</returns> public bool Insert(Hot_Search model, IDbConnection connection = null, IDbTransaction transaction = null) { var insert = new LambdaInsert <Hot_Search>(); if (!model.SearchWord.IsNullOrEmpty()) { insert.Insert(p => p.SearchWord == model.SearchWord); } if (!model.Amount.IsNullOrEmpty()) { insert.Insert(p => p.Amount == model.Amount); } return(insert.GetInsertResult(connection, transaction) >= 0); }
/// <summary> /// 根据模型更新 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>是否成功</returns> public bool Update(Hot_Search model, IDbConnection connection = null, IDbTransaction transaction = null) { var update = new LambdaUpdate <Hot_Search>(); if (!model.Id.IsNullOrEmpty()) { update.Where(p => p.Id == model.Id); } if (!model.SearchWord.IsNullOrEmpty()) { update.Set(p => p.SearchWord == model.SearchWord); } if (!model.Amount.IsNullOrEmpty()) { update.Set(p => p.Amount == model.Amount); } return(update.GetUpdateResult(connection, transaction)); }
/// <summary> /// 数据条数 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>对象列表</returns> public int SelectCount(Hot_Search model = null, IDbConnection connection = null, IDbTransaction transaction = null) { var query = new LambdaQuery <Hot_Search>(); if (model != null) { if (!model.Id.IsNullOrEmpty()) { query.Where(p => p.Id == model.Id); } if (!model.SearchWord.IsNullOrEmpty()) { query.Where(p => p.SearchWord == model.SearchWord); } if (!model.Amount.IsNullOrEmpty()) { query.Where(p => p.Amount == model.Amount); } } return(query.GetQueryCount(connection, transaction)); }
/// <summary> /// 根据模型删除数据 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>是否成功</returns> public bool DeleteModel(Hot_Search model = null, IDbConnection connection = null, IDbTransaction transaction = null) { var delete = new LambdaDelete <Hot_Search>(); if (model != null) { if (!model.Id.IsNullOrEmpty()) { delete.Where(p => p.Id == model.Id); } if (!model.SearchWord.IsNullOrEmpty()) { delete.Where(p => p.SearchWord == model.SearchWord); } if (!model.Amount.IsNullOrEmpty()) { delete.Where(p => p.Amount == model.Amount); } } return(delete.GetDeleteResult(connection, transaction)); }
/// <summary> /// 筛选全部数据 /// </summary> /// <param name="model">模型</param> /// <param name="connection">连接</param> /// <param name="transaction">事务</param> /// <returns>对象列表</returns> public List <Hot_Search> SelectAll(Hot_Search model = null, string SelectFiled = null, IDbConnection connection = null, IDbTransaction transaction = null) { var query = new LambdaQuery <Hot_Search>(); if (model != null) { if (!model.Id.IsNullOrEmpty()) { query.Where(p => p.Id == model.Id); } if (!model.SearchWord.IsNullOrEmpty()) { query.Where(p => p.SearchWord == model.SearchWord); } if (!model.Amount.IsNullOrEmpty()) { query.Where(p => p.Amount == model.Amount); } } if (SelectFiled != null) { SelectFiled = SelectFiled.ToLowerInvariant(); if (SelectFiled.Contains("id,")) { query.Select(p => new { p.Id }); } if (SelectFiled.Contains("searchword,")) { query.Select(p => new { p.SearchWord }); } if (SelectFiled.Contains("amount,")) { query.Select(p => new { p.Amount }); } } return(query.GetQueryList(connection, transaction)); }
/// <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 <Hot_Search> SelectByPage(string Key, int start, int PageSize, bool desc = true, Hot_Search model = null, string SelectFiled = null, IDbConnection connection = null, IDbTransaction transaction = null) { var query = new LambdaQuery <Hot_Search>(); if (model != null) { if (!model.Id.IsNullOrEmpty()) { query.Where(p => p.Id == model.Id); } if (!model.SearchWord.IsNullOrEmpty()) { query.Where(p => p.SearchWord == model.SearchWord); } if (!model.Amount.IsNullOrEmpty()) { query.Where(p => p.Amount == model.Amount); } } if (SelectFiled != null) { SelectFiled = SelectFiled.ToLowerInvariant(); if (SelectFiled.Contains("id,")) { query.Select(p => new { p.Id }); } if (SelectFiled.Contains("searchword,")) { query.Select(p => new { p.SearchWord }); } if (SelectFiled.Contains("amount,")) { query.Select(p => new { p.Amount }); } } if (Key != null) { query.OrderByKey(Key, desc); } return(query.GetQueryPageList(start, PageSize, connection, transaction)); }
/// <summary> /// 筛选全部数据 /// </summary> /// <param name="model">模型</param> /// <returns>对象列表</returns> public List <Hot_Search> SelectByModel(Hot_Search model) { return(Hot_SearchOper.Instance.SelectAll(model)); }
/// <summary> /// 数据条数 /// </summary> /// <param name="model">模型</param> /// <returns>对象列表</returns> public int SelectCount(Hot_Search model) { return(Hot_SearchOper.Instance.SelectCount(model)); }
/// <summary> /// 根据模型插入 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public int InsertReturnKey(Hot_Search model) { return(Hot_SearchOper.Instance.InsertReturnKey(model)); }
/// <summary> /// 根据模型插入 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public bool Insert(Hot_Search model) { return(Hot_SearchOper.Instance.Insert(model)); }
/// <summary> /// 根据模型更新 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public bool Update(Hot_Search model) { return(Hot_SearchOper.Instance.Update(model)); }
/// <summary> /// 根据模型删除数据 /// </summary> /// <param name="model">模型</param> /// <returns>是否成功</returns> public bool DeleteModel(Hot_Search model) { return(Hot_SearchOper.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 <Hot_Search> SelectByPage(string Key, int start, int PageSize, bool desc, Hot_Search model, string SelectFiled) { return(Hot_SearchOper.Instance.SelectByPage(Key, start, PageSize, desc, model)); }