Exemple #1
0
        public PagedList <dynamic> GetPagedList(string tableName, object paramater)
        {
            var pageSize   = 0;
            var pageIndex  = 0;
            var dictionary = paramater.DeserializeJson <Dictionary <string, string> >();

            if (dictionary != null)
            {
                var pagedInput = AutoMapping.SetValue <PagedInputDto>(dictionary);
                if (pagedInput != null)
                {
                    pageSize  = (int)pagedInput.PageSize;
                    pageIndex = (int)pagedInput.PageIndex;
                }
            }

            if (pageSize < 1)
            {
                pageSize = 1;
            }

            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            dictionary.Remove("PageSize");
            dictionary.Remove("PageIndex");

            var listOp = new List <(string Field, Operator op, string Value)>();

            foreach (var item in dictionary)
            {
                var rs = LightAppStore.ComparisonParse(item);
                listOp.Add(rs);
            }

            var filter    = LightAppStore.FilterParser(listOp);
            var fetchList = LightAppStore.GetCollection(tableName).Find(filter)
                            .Skip(pageSize * (pageIndex - 1)).Limit(pageSize)
                            .ToList();
            var totalCount = LightAppStore.GetCollection(tableName).Find(filter).CountDocuments();

            var pagedList = PagedList <dynamic> .Create(fetchList, totalCount, pageSize, pageIndex);

            return(pagedList);
        }
Exemple #2
0
        public List <dynamic> GetList(string tableName, Dictionary <string, string> query)
        {
            if (tableName.IsNullOrEmpty())
            {
                tableName = query.GetValue("TableName");
                query.Remove("TableName");
            }

            var listOp = new List <(string Field, Operator op, string Value)>();

            foreach (var item in query)
            {
                var rs = LightAppStore.ComparisonParse(item);
                listOp.Add(rs);
            }

            var rsList = LightAppStore.QueryList(tableName, listOp).ToList();

            return(rsList);
        }