コード例 #1
0
ファイル: NZBServices.cs プロジェクト: tehsu/fastNZB
        public object Any(QueryTitles query)
        {
            var q     = AutoQuery.CreateQuery(query, base.Request);
            var words = query.NameQuery.Split(' ');
            var count = 0;

            foreach (string word in words)
            {
                var w = word;

                if (w.Contains("^") && count == 0)
                {
                    q.And(q2 => q2.Name.StartsWith(w.Substring(1)));
                }
                else if (w.Contains("--"))
                {
                    q.And(q2 => q2.Name.Contains(w.Substring(2)));
                }
                else
                {
                    q.And(q2 => q2.Name.Contains(w));
                }

                count++;
            }

            return(AutoQuery.Execute(new QueryTitles(), q));
        }
コード例 #2
0
ファイル: CatalogService.cs プロジェクト: JFigue27/MDC
        public object Get(GetOnlyValues request)
        {
            var query = AutoQuery.CreateQuery(request, Request);

            return(WithDb(db =>
            {
                if (!string.IsNullOrWhiteSpace(request.CatalogType))
                {
                    var catalogDefinition = db.Single <CatalogDefinition>(e => e.Name == request.CatalogType);
                    if (catalogDefinition != null)
                    {
                        query.Where(e => e.CatalogDefinitionId == catalogDefinition.Id);
                    }
                    else
                    {
                        throw new Exception($"Catalog does not exist: [{request.CatalogType}]");
                    }
                }

                CommonResponse commonResponse = Logic.GetPaged(
                    request.Limit,
                    request.Page,
                    request.FilterGeneral,
                    query,
                    requiresKeysInJsons: request.RequiresKeysInJsons
                    );
                var result = commonResponse.Result as List <Catalog>;
                return result.Select(e => e.Value);
            }));
        }
コード例 #3
0
    public override object Exec <From>(IQuery <From> dto)
    {
        var q       = AutoQuery.CreateQuery(dto, Request);
        var session = base.SessionAs <CustomUserSession>();

        q.And("CustomerId = {0}", session.CustomerId);
        return(AutoQuery.Execute(dto, q));
    }
コード例 #4
0
        public object Get(GetPagedActivitys request)
        {
            var query = AutoQuery.CreateQuery(request, Request);

            return(WithDb(db => Logic.GetPaged(
                              request.Limit,
                              request.Page,
                              request.FilterGeneral,
                              query,
                              requiresKeysInJsons: request.RequiresKeysInJsons
                              )));
        }
コード例 #5
0
        public object Get(GetPagedCrossCatalogDefinitionFields request)
        {
            var query = AutoQuery.CreateQuery(request, Request);

            return(WithDb(db => Logic.GetPaged(
                              request.Limit,
                              request.Page,
                              request.FilterGeneral,
                              query,
                              requiresKeysInJsons: request.RequiresKeysInJsons
                              )));
        }
コード例 #6
0
        [CacheResponse(Duration = 60, MaxAge = 30)]  //前30秒返回缓存数据   后30秒回校验数据是否改变
        public object Get(OperationRecords request)
        {
            var query  = AutoQuery.CreateQuery(request, Request);
            var result = AutoQuery.Execute(request, query);

            //return new HttpResult(result)
            //{
            //    ResultScope = () =>
            //        JsConfig.With(new Config { IncludeNullValues = true, ExcludeDefaultValues = true })
            //};

            return(result);
        }
コード例 #7
0
        /// <summary>
        /// 基于 AutoQuery 实现统一的业务表动态查询。
        /// <see cref="http://docs.servicestack.net/autoquery-rdbms"/>
        /// </summary>
        /// <param name="query">包含显示表名及隐式的其它查询条件</param>
        /// <exception cref="UserFriendlyException"></exception>
        public async Task <IQueryResponse> Get(GetBizs query)
        {
            if (string.IsNullOrEmpty(query.TableName))
            {
                throw new UserFriendlyException("表参数不能为空。");
            }

            if (!query.TableName.StartsWith("biz_"))
            {
                throw new UserFriendlyException("只能查询业务表。");
            }

            // 根据表名得到表结构,并且根据表结构动态生成实体
            var entityType = await CreateBizType(query.TableName);

            // 动态生成用于 AutoQuery 的请求对象, 必须继承自 QueryDb<>
            // TODO: 通过设置 NamedConnection 可以自动实现分库的查询
            var routeBaseType = typeof(QueryDb <>).MakeGenericType(entityType);
            var routeType     = await ReflectionManage.CreateEntityType(new EntityDef
            {
                Name       = $"{query.TableName}_route",
                BaseType   = routeBaseType,
                Properties = Enumerable.Empty <EntityProperty>()
            });

            var queryObj = Activator.CreateInstance(routeType);

            // 设置分页参数
            if (query.Skip.HasValue && query.Take.HasValue)
            {
                ((QueryBase)queryObj).Skip = query.Skip;
                ((QueryBase)queryObj).Take = query.Take;
            }

            if (!string.IsNullOrEmpty(query.OrderBy))
            {
                ((QueryBase)queryObj).OrderBy = query.OrderBy;
            }

            if (!string.IsNullOrEmpty(query.OrderByDesc))
            {
                ((QueryBase)queryObj).OrderByDesc = query.OrderByDesc;
            }

            // 调用 AutoQuery 实现动态表查询
            var q      = AutoQuery.CreateQuery((IQueryDb)queryObj, Request.GetRequestParams(), Request);
            var result = AutoQuery.Execute((IQueryDb)queryObj, q);

            return(await Task.FromResult(result));
        }
コード例 #8
0
        public object Get(GetOnlyValues request)
        {
            var query = AutoQuery.CreateQuery(request, Request);

            return(WithDb(db =>
            {
                CommonResponse commonResponse = Logic.GetPaged(
                    request.Limit,
                    request.Page,
                    request.FilterGeneral,
                    query,
                    requiresKeysInJsons: request.RequiresKeysInJsons
                    );

                var result = commonResponse.Result as List <Catalog>;
                return result.Select(e => e.Value);
            }));
        }
コード例 #9
0
        public override object Exec <From, Into>(IQueryDb <From, Into> dto)
        {
            var q = AutoQuery.CreateQuery(dto, Request.GetRequestParams(), base.Request);

            return(AutoQuery.Execute(dto, q, base.Request));
        }
コード例 #10
0
ファイル: Global.asax.cs プロジェクト: khizar-17/Test-1
        public override object Exec <From>(IQuery <From> dto)
        {
            var q = AutoQuery.CreateQuery(dto, Request.GetRequestParams());

            return(AutoQuery.Execute(dto, q));
        }