Ejemplo n.º 1
0
        protected LiteQuery GetRefSubQuery(string refTableName, string refKeyName, string refDisplayName, string foreignTableAlias, string foreignName)
        {
            string    tableAlias = string.Empty;
            LiteQuery query      = LiteQuery.New(refTableName, tableAlias);

            query.AddField(tableAlias, refDisplayName);
            query.Filter = FilterField.New(tableAlias, refKeyName).Equal(foreignTableAlias, foreignName);
            return(query);
        }
Ejemplo n.º 2
0
        public LiteQuery GetMMSubQuery(string innnerTableName, string leftFieldName, string rightFieldName, object rightValue)
        {
            string    tableAlias = string.Empty;
            LiteQuery query      = LiteQuery.New(innnerTableName, tableAlias);

            query.AddField(tableAlias, leftFieldName);
            query.Filter = FilterField.New(tableAlias, rightFieldName).Equal(rightValue);
            return(query);
        }
Ejemplo n.º 3
0
        protected LiteFilter GetFilterForMultiColumns(string tableAlias, string fields, object o)
        {
            List <string> list = (from p in fields.Split(new char[] { ',' })
                                  where !string.IsNullOrEmpty(p)
                                  select p).ToList <string>();
            LiteFilter filter = LiteFilter.False();

            foreach (string str in list)
            {
                filter = filter.Or(FilterField.New(tableAlias, str).Contains(o));
            }
            return(filter);
        }
Ejemplo n.º 4
0
        protected LiteFilter GetFilterForMultiValues(string tableAlias, string fieldName, object o)
        {
            List <int> list = (from p in Convert.ToString(o).Split(new char[] { ',' })
                               select p.ToIntNullable() into p
                               where p.HasValue
                               select p.Value).ToList <int>();
            LiteFilter filter = LiteFilter.False();

            foreach (int num in list)
            {
                filter = filter.Or(FilterField.New(tableAlias, fieldName).Equal(num));
            }
            return(filter);
        }
Ejemplo n.º 5
0
        public static LiteFilter GetFilter(this ViewQueryEx ve)
        {
            switch (ve.CompareType)
            {
            case CompareTypeEnum.LessThan:
                return(FilterField.New(ve.TableAlias, ve.FieldName).LessThan(ve.ConditionValue));

            case CompareTypeEnum.LessThanOrEqual:
                return(FilterField.New(ve.TableAlias, ve.FieldName).LessThanOrEqual(ve.ConditionValue));

            case CompareTypeEnum.Equal:
                return(FilterField.New(ve.TableAlias, ve.FieldName).Equal(ve.ConditionValue));

            case CompareTypeEnum.GreaterThanOrEqual:
                return(FilterField.New(ve.TableAlias, ve.FieldName).GreaterThanOrEqual(ve.ConditionValue));

            case CompareTypeEnum.GreaterThan:
                return(FilterField.New(ve.TableAlias, ve.FieldName).GreaterThan(ve.ConditionValue));

            case CompareTypeEnum.EndWith:
                return(FilterField.New(ve.TableAlias, ve.FieldName).EndWith(ve.ConditionValue));

            case CompareTypeEnum.StartWith:
                return(FilterField.New(ve.TableAlias, ve.FieldName).StartWith(ve.ConditionValue));

            case CompareTypeEnum.Contains:
                return(FilterField.New(ve.TableAlias, ve.FieldName).Contains(ve.ConditionValue));

            case CompareTypeEnum.NotEqual:
                return(FilterField.New(ve.TableAlias, ve.FieldName).NotEqual(ve.ConditionValue));

            case CompareTypeEnum.IN:
                return(FilterField.New(ve.TableAlias, ve.FieldName).IN(ve.SubQuery));

            case CompareTypeEnum.IsNull:
                return(FilterField.New(ve.TableAlias, ve.FieldName).IsNull());

            case CompareTypeEnum.IsNotNull:
                return(FilterField.New(ve.TableAlias, ve.FieldName).IsNotNull());
            }
            throw new Exception(string.Format("暂不支持动态添加{0}类型查询条件!", CompareTypeEnum.StartWith.ToString()));
        }
Ejemplo n.º 6
0
        public override DataTable Query()
        {
            var q = LiteQuery.New("T_User", "a");

            q.SelectFields.Add(LiteField.NewEntityField("a", "User_ID"));
            q.SelectFields.Add(LiteField.NewEntityField("a", "User_Name"));
            q.SelectFields.Add(LiteField.NewEntityField("a", "User_Code"));
            q.SelectFields.Add(LiteField.NewEntityField("a", "Department_ID"));
            q.SelectFields.Add(LiteField.NewEntityField("a", "User_Mobile"));

            var subQ = GetRefSubQuery("T_Department", "Department_ID", "Department_Name", "a", "Department_ID");

            q.SelectFields.Add(LiteField.NewSubQueryField(subQ, "Department_ID_V"));

            q.Filter = LiteFilter.True();

            if (!string.IsNullOrEmpty(this.UserName))
            {
                var fUserName = FilterField.New("a", "User_Name").Contains(this.UserName);
                q.Filter = q.Filter.And(fUserName);
            }
            if (!string.IsNullOrEmpty(this.UserCode))
            {
                var fUserCode = FilterField.New("a", "User_Code").Contains(this.UserCode);
                q.Filter = q.Filter.And(fUserCode);
            }
            if (this.DepartmentId != null)
            {
                var fDeptId = FilterField.New("a", "Department_ID").Equal(this.DepartmentId.Value);
                q.Filter = q.Filter.And(fDeptId);
            }

            AddFilterForPrevilege(q);
            AddFilterForShared(q);

            q.SkipNumber = this.PageIndex * this.PageSize;
            q.TakeNumber = this.PageSize;

            return(this.DataHelper.ExecuteLiteQuery(q));
        }