Esempio n. 1
0
        public virtual MDXWhere ToWhere()
        {
            //获取所有的需要转未子查询的属性
            var properties   = this.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
            var whereItmPros = properties.Where(p => p.GetCustomAttributes(typeof(CriteriaPropertyAttribute), false).FirstOrDefault(t => ((CriteriaPropertyAttribute)t).Type == CriteriaBuildType.Where) != null);

            //构造子查询Cube
            MDXWhere where = new MDXWhere();
            foreach (var s in whereItmPros)
            {
                var     attr  = (CriteriaPropertyAttribute)s.GetCustomAttributes(typeof(CriteriaPropertyAttribute), false).FirstOrDefault();
                dynamic value = s.GetValue(this);
                switch (attr.Opration)
                {
                case CriteriaOprations.Eq:
                    if (value != null)
                    {
                        var item = this.ToWhereItem(attr, value);
                        where.And(item);
                    }
                    break;

                default:
                    if (value != null && value.Length > 0)
                    {
                        var item = this.ToWhereItem(attr, value);
                        where.And(item);
                    }
                    break;
                }
            }

            return(where);
        }
Esempio n. 2
0
        public static void GetWhere(CriteriaPropertyAttribute attr, dynamic value, MDXWhere where)
        {
            switch (attr.Opration)
            {
            case CriteriaOprations.Eq:
                if (value != null)
                {
                    var item = ToWhereItem(attr, value);
                    where.And(item);
                }
                break;

            default:
                if (value != null && value.Length > 0)
                {
                    var item = ToWhereItem(attr, value);
                    where.And(item);
                }
                break;
            }
        }