public Models.PageResult <Entities.DynamicForm> Query(string formID, Models.PageParam <Models.DynamicForm.Condition> pageParam)
        {
            var filter     = this.BuildFilter(pageParam.Condition);
            var collection = this.DynamicForms(formID).Find(filter);
            var result     = new Models.PageResult <Entities.DynamicForm>();

            result.Total = collection.Count();
            result.Data  = collection.Sort(pageParam).Pagination(pageParam).ToList();
            return(result);
        }
Exemple #2
0
        public Models.PageResult <Models.Permit.QueryResultData> Query(Models.PageParam <Models.Permit.Condition> pageParam)
        {
            var filter     = this.BuildFilter(pageParam.Condition);
            var collection = this.Collection.Find(filter);
            var result     = new Models.PageResult <Models.Permit.QueryResultData>();

            result.Total = collection.Count();
            var projections = new ProjectionDefinition <Entities.Permit>[]
            {
                Builders <Entities.Permit> .Projection.Include(nameof(Entities.Permit.ID)),
                Builders <Entities.Permit> .Projection.Include(nameof(Entities.Permit.Name)),
                Builders <Entities.Permit> .Projection.Include(nameof(Entities.Permit.Code))
            };
            var projection = Builders <Entities.Permit> .Projection.Combine(projections);

            var list = collection.Sort(pageParam).Pagination(pageParam).Project(projection).As <Entities.Permit>().ToList();

            result.Data = AutoMapper.Mapper.Map <List <Models.Permit.QueryResultData> >(list);
            return(result);
        }