/// <summary> /// 根据条件查询 /// </summary> /// <param name="condition">查询条件,如为null或为空则查询所有</param> /// <param name="orderPropertyColl"></param> /// <returns></returns> protected virtual IList <T> Select(Hashtable condition, NameValueCollection orderPropertyColl = null) { AddOrderPropertyCondition(condition, orderPropertyColl); Hashtable ht = DaoHelper.ProcessConditionHashtable(condition); return(_sqlMapper.QueryForList <T>(GetStatementIdWithNamespace(SqlMapConstants.SelectStatementId), ht)); }
/// <summary> /// 根据条件分页查询(虚方法,可重写) /// </summary> /// <param name="startRecordIndex">当前页数据记录的起始索引,从1开始</param> /// <param name="pageSize">每页显示的记录数</param> /// <param name="condition">查询条件,如为null或未设置查询条件则查询所有</param> /// <param name="orderPropertyColl">排序条件</param> /// <returns>查询结果</returns> public virtual IList <T> SelectByPage(int startRecordIndex, int pageSize, Hashtable condition = null, NameValueCollection orderPropertyColl = null) { AddOrderPropertyCondition(condition, orderPropertyColl); Hashtable ht = DaoHelper.ProcessConditionHashtable(condition); DaoHelper.SetPageArg(ref ht, startRecordIndex, pageSize); return(_sqlMapper.QueryForList <T>(GetStatementIdWithNamespace(SqlMapConstants.SelectByPageStatementId), ht)); }
/// <summary> /// 根据条件删除 /// </summary> /// <param name="condition">删除条件,如为null或空则不进行删除</param> /// <returns>删除数量</returns> protected virtual int Delete(Hashtable condition) { Hashtable ht = DaoHelper.ProcessConditionHashtable(condition); if (ht == null || ht.Count == 0) { return(default(int)); } return(_sqlMapper.Delete(GetStatementIdWithNamespace(SqlMapConstants.DeleteStatementId), ht)); }
/// <summary> /// 根据查询条件更新关联领域对象(虚方法,可重写) /// </summary> /// <param name="relatedDomain">更新关联领域对象的值</param> /// <param name="relatedDomainId">更新关联领域对象Id的值</param> /// <param name="condition">查询条件</param> /// <returns>更新记录数</returns> public virtual int UpdateRelated(string relatedDomain, string relatedDomainId, Hashtable condition) { if (condition == null || condition.Count == 0) { return(default(int)); } Hashtable ht = CreateRelatedConditionHashtable(relatedDomain, relatedDomainId, condition); ht = DaoHelper.ProcessConditionHashtable(ht); return(_sqlMapper.Update(GetStatementIdWithNamespace(SqlMapConstants.UpdateRelatedStatementId), ht)); }
/// <summary> /// 根据条件查询顶部指定数量的数据,此方法使用SELECT TOP语句进行查询 /// </summary> /// <param name="topCount">查询数量</param> /// <param name="condition">查询条件,如为null或空则查询所有</param> /// <param name="orderPropertyColl">排序条件</param> /// <returns>查询结果</returns> protected virtual IList <T> SelectTop(int topCount, Hashtable condition, NameValueCollection orderPropertyColl) { if (condition == null) { condition = new Hashtable(); } if (condition.ContainsKey(SqlMapConstants.TopCountParam)) { throw new DaoException("查询条件Hashtable中不能定义名称为" + SqlMapConstants.TopCountParam + "的Key。"); } condition.Add(SqlMapConstants.TopCountParam, topCount); AddOrderPropertyCondition(condition, orderPropertyColl); Hashtable ht = DaoHelper.ProcessConditionHashtable(condition); return(_sqlMapper.QueryForList <T>(GetStatementIdWithNamespace(SqlMapConstants.SelectTopStatementId), ht)); }
/// <summary> /// 根据条件类查询数量 /// </summary> /// <param name="condition">查询条件,如为null或空则查询所有</param> /// <returns>返回数量结果</returns> protected virtual int SelectCount(Hashtable condition = null) { Hashtable ht = DaoHelper.ProcessConditionHashtable(condition); return((int)_sqlMapper.QueryForObject(GetStatementIdWithNamespace(SqlMapConstants.SelectCountStatementId), ht)); }