示例#1
0
        /// <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;
            }
        }
示例#2
0
文件: UnitTest1.cs 项目: jeanmahai/zj
 public void TestMethodQueryGifts()
 {
     GiftQueryFilter filter = new GiftQueryFilter()
     {
         PageIndex = 1,
         PageSize = 10,
         SysNo = 1003
     };
     var data = GiftsMgtService.Instance.QueryGifts(filter);
 }