public virtual string BuildStatistics(StatisticsInfo info)
        {
            StringBuilder statisticsBuilder = new StringBuilder();

            if (info == null)
            {
                throw new ArgumentException("统计信息不能为空!", "filter");
            }
            //包含不合法的参数则直接抛出异常
            if (info.StatisticsRelation != StatisticsRelationEnum.Count && string.IsNullOrWhiteSpace(info.FieldName))
            {
                throw new ArgumentException("字段名称不能为空!", "FieldName");
            }

            if (string.IsNullOrWhiteSpace(info.TableName))
            {
                throw new ArgumentException("表名不能为空!", "TableName");
            }
            string expression = StatisticsRelationDictData[info.StatisticsRelation];

            statisticsBuilder.Append(expression.Replace(Constants.ReplaceTableName, info.TableName).Replace(Constants.ReplaceFieldName, info.FieldName));
            return(statisticsBuilder.ToString());
        }
        public void BuildWhereWithOrderTest()
        {
            //筛选出用户Id大于平均值的,并且密保问题不为空的用户
            StatisticsInfo statisticsFilter = new StatisticsInfo()
            {
                TableName = "UserInfo",
                FieldName = "UserId",
                StatisticsRelation = StatisticsRelationEnum.Avg
            };

            string avgSql = _provider.BuildStatistics(statisticsFilter);

            var normalList = new List<NormalFilterInfo>() { 
            new NormalFilterInfo(){
                FieldName="UserId",
                FieldType= FieldTypeEnum.Number,
                ConnectRelation= ConnectRelationEnum.And,
                NormalWhereRelation= NormalWhereRelationEnum.MoreThan,
                WhereValue=avgSql
            },
            new NormalFilterInfo(){
                FieldName="PwdQuestion",
                FieldType= FieldTypeEnum.Text,
                ConnectRelation= ConnectRelationEnum.And,
                NormalWhereRelation= NormalWhereRelationEnum.IsNotNull,
            }
            };

            List<OrderInfo> orderList = new List<OrderInfo>() { 
                new OrderInfo(){
                    FieldName = "UserId",
                    OrderMode = OrderModeEnum.Asc
                },
                new OrderInfo(){
                    FieldName = "Email",
                    OrderMode = OrderModeEnum.Desc
                },
            };

            FilterInfo filterInfo = new FilterInfo();
            filterInfo.NormalFilterInfoList = normalList;
            filterInfo.OrderInfoList = orderList;


            string sql = _provider.BuildWhere(filterInfo);
        }
 public void BuildStatisticsTest_Count()
 {
     StatisticsInfo filter = new StatisticsInfo()
     {
         TableName = "UserInfo",
         StatisticsRelation = StatisticsRelationEnum.Count
     };
     string sql = _provider.BuildStatistics(filter);
 }
 public void BuildStatisticsTest_Max()
 {
     StatisticsInfo filter = new StatisticsInfo()
     {
         FieldName = "UserId",
         TableName = "UserInfo",
         StatisticsRelation = StatisticsRelationEnum.Max
     };
     string sql = _provider.BuildStatistics(filter);
 }
        public virtual string BuildStatistics(StatisticsInfo info)
        {
            StringBuilder statisticsBuilder = new StringBuilder();
            if (info == null)
            {
                throw new ArgumentException("统计信息不能为空!", "filter");
            }
            //包含不合法的参数则直接抛出异常
            if (info.StatisticsRelation != StatisticsRelationEnum.Count && string.IsNullOrWhiteSpace(info.FieldName))
            {
                throw new ArgumentException("字段名称不能为空!", "FieldName");
            }

            if (string.IsNullOrWhiteSpace(info.TableName))
            {
                throw new ArgumentException("表名不能为空!", "TableName");
            }
            string expression = StatisticsRelationDictData[info.StatisticsRelation];
            statisticsBuilder.Append(expression.Replace(Constants.ReplaceTableName, info.TableName).Replace(Constants.ReplaceFieldName, info.FieldName));
            return statisticsBuilder.ToString();
        }