示例#1
0
        public ActionResult GetPlistViews(GetPlistViews requestModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.ModelState.ToJsonResult());
            }
            var data = AcDomain.GetPlistViews(requestModel);

            Debug.Assert(requestModel.Total != null, "requestModel.total != null");
            return(this.JsonResult(new MiniGrid <DbView> {
                total = requestModel.Total.Value, data = data
            }));
        }
示例#2
0
        public static IQueryable <DbView> GetPlistViews(this IAcDomain acDomain, GetPlistViews requestModel)
        {
            if (!requestModel.DatabaseId.HasValue)
            {
                throw new ValidationException("databaseId为空");
            }
            RdbDescriptor db;

            if (!acDomain.RdbSet.TryDb(requestModel.DatabaseId.Value, out db))
            {
                throw new ValidationException("意外的数据库Id");
            }
            var properties = new HashSet <string>()
            {
                "Id",
                "DatabaseId",
                "CatalogName",
                "SchemaName",
                "Name",
                "Description"
            };

            foreach (var filter in requestModel.Filters)
            {
                if (!properties.Contains(filter.field))
                {
                    throw new ValidationException("意外的DbView实体类型属性" + filter.field);
                }
            }
            int pageIndex = requestModel.PageIndex;
            int pageSize  = requestModel.PageSize;
            var queryable = db.DbViews.Values.Select(a => a).AsQueryable();

            foreach (var filter in requestModel.Filters)
            {
                queryable = queryable.Where(filter.ToPredicate(), filter.value);
            }
            requestModel.Total = queryable.Count();

            return(queryable.OrderBy(requestModel.SortField + " " + requestModel.SortOrder).Skip(pageIndex * pageSize).Take(pageSize));
        }
示例#3
0
        public static IQueryable<DbView> GetPlistViews(this IAcDomain acDomain, GetPlistViews requestModel)
        {
            if (!requestModel.DatabaseId.HasValue)
            {
                throw new ValidationException("databaseId为空");
            }
            RdbDescriptor db;
            if (!acDomain.Rdbs.TryDb(requestModel.DatabaseId.Value, out db))
            {
                throw new ValidationException("意外的数据库Id");
            }
            var properties = new HashSet<string>()
            {
                "Id",
                "DatabaseId",
                "CatalogName",
                "SchemaName",
                "Name",
                "Description"
            };
            foreach (var filter in requestModel.Filters)
            {
                if (!properties.Contains(filter.field))
                {
                    throw new ValidationException("意外的DbView实体类型属性" + filter.field);
                }
            }
            int pageIndex = requestModel.PageIndex;
            int pageSize = requestModel.PageSize;
            var queryable = db.DbViews.Values.Select(a => a).AsQueryable();
            foreach (var filter in requestModel.Filters)
            {
                queryable = queryable.Where(filter.ToPredicate(), filter.value);
            }
            requestModel.Total = queryable.Count();

            return queryable.OrderBy(requestModel.SortField + " " + requestModel.SortOrder).Skip(pageIndex * pageSize).Take(pageSize);
        }
示例#4
0
        public ActionResult GetPlistViews(GetPlistViews requestModel)
        {
            if (!ModelState.IsValid)
            {
                return this.ModelState.ToJsonResult();
            }
            var data = AcDomain.GetPlistViews(requestModel);

            Debug.Assert(requestModel.Total != null, "requestModel.total != null");
            return this.JsonResult(new MiniGrid<DbView> { total = requestModel.Total.Value, data = data });
        }