/// <summary> /// 查询奖品 /// </summary> /// <param name="filter">查询条件</param> /// <returns></returns> public static QueryResult<Gift> QueryGifts(GiftQueryFilter filter) { QueryResult<Gift> result = new QueryResult<Gift>(); result.ServicePageIndex = filter.ServicePageIndex; result.PageSize = filter.PageSize; PagingInfoEntity page = DataAccessUtil.ToPagingInfo(filter); CustomDataCommand cmd = DataCommandManager.CreateCustomDataCommandFromConfig("QueryGifts"); using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, "SysNo DESC")) { sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "Status", DbType.Int32, "@Status1", QueryConditionOperatorType.NotEqual, CommonStatus.Deleted); sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "SysNo", DbType.Int32, "@SysNo", QueryConditionOperatorType.Equal, filter.SysNo); sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "GiftName", DbType.String, "@GiftName", QueryConditionOperatorType.Like, filter.GiftName); sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "GiftID", DbType.String, "@GiftID", QueryConditionOperatorType.Like, filter.GiftID); sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "Descriptions", DbType.String, "@Descriptions", QueryConditionOperatorType.Like, filter.Descriptions); sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "MarketPrice", DbType.Decimal, "@MarketPrice", QueryConditionOperatorType.Like, filter.MarketPrice); sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "Status", DbType.Int32, "@Status", QueryConditionOperatorType.Equal, filter.Status); cmd.CommandText = sqlBuilder.BuildQuerySql(); result.ResultList = cmd.ExecuteEntityList<Gift>(); result.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount")); return result; } }
public void TestMethodQueryGifts() { GiftQueryFilter filter = new GiftQueryFilter() { PageIndex = 1, PageSize = 10, SysNo = 1003 }; var data = GiftsMgtService.Instance.QueryGifts(filter); }