コード例 #1
0
        public JsonQueryResult ExecuteQuery(JsonQueryRequest request)
        {
            // From
            var queryable = _GetQueryableByName(request.From.Name);

            // Where
            if (request.Where != null && request.Where.Any())
            {
                queryable = _BuildWhereQueryable(queryable, request.Where);
            }

            // OrderBy
            if (request.OrderBy != null && request.OrderBy.Any())
            {
                queryable = _BuildOrderByQueryable(queryable, request.OrderBy);
            }

            // Limit
            if (request.Limit != null)
            {
                queryable = _BuildLimitQueryable(queryable, request.Limit);
            }

            // Select
            var resultsQueryable = _BuildSelectQueryable(queryable, request.Select) as IQueryable <object[]>;
            var results          = resultsQueryable.ToList();

            // Return
            var result = _BuildResult(request, results);

            return(result);
        }
コード例 #2
0
        private JsonQueryResult _BuildResult(JsonQueryRequest request, List <object[]> data)
        {
            var result = new JsonQueryResult()
            {
                Columns = request.Select
                          .Select(t => new JsonQueryResultColumn()
                {
                    Name = t.Name ?? t.Selector
                })
                          .ToList(),
                Rows = data
                       .Select(t => new JsonQueryResultRow()
                {
                    Data = t
                })
                       .ToList()
            };

            return(result);
        }