示例#1
0
        //\p [rp,][hostname:][portnumber|servicename]
        public static QueryResultObject Query(string host, int port, string Credentials,
                                              string CreateQuery, string ReturnQuery)
        {
            c c = new c(host, port, Credentials);

            Object result = c.k(ReturnQuery); // query the table using a sync msg (c.k)

            c.ks(CreateQuery);                // create example table using async msg (c.ks)
            c.Flip flip     = c.td(result);   // if the result set is a keyed table, this removes the key.
            int    nRows    = c.n(flip.y[0]); // flip.y is an array of columns. Get the number of rows from the first column.
            int    nColumns = c.n(flip.x);    // flip.x is an array of column names

            Console.WriteLine("Number of columns: " + c.n(flip.x));
            Console.WriteLine("Number of rows:    " + nRows);
            string csvMessage = "";
            var    lst        = new List <string>();

            csvMessage = FormatData(flip, nRows, nColumns, csvMessage, lst);
            var queryObject = new QueryResultObject();

            queryObject.result = csvMessage;
            System.Console.WriteLine("\n Sent Event: " + csvMessage);
            c.Close();
            return(queryObject);
        }
示例#2
0
        public async ValueTask <QueryResultObject <T> > Find(ISpecification <T> specification = null)
        {
            var qro = new QueryResultObject <T>(specification.PageSize, specification.CurrentPage);

            qro.SetQueryResult(await ApplySpecification(specification, qro).ToListAsync());
            return(qro);
        }
示例#3
0
        private IQueryable <T> ApplySpecification(ISpecification <T> specification, QueryResultObject <T> qro)
        {
            var query = ApplySpecification(specification);

            query = SpecificationEvaluator <T> .GetPagiedQuery(query, specification, qro);

            return(query);
        }
示例#4
0
        public static IQueryable <T> GetPagiedQuery(IQueryable <T> sourceQuery, ISpecification <T> specification, QueryResultObject <T> qro)
        {
            var query = sourceQuery;

            qro.TotalCount = query.Count();

            if (qro.TotalCount > 0 && specification.IsPagingEnabled)
            {
                qro.LastPage    = (int)Math.Ceiling(qro.TotalCount / (double)qro.PageSize);
                qro.CurrentPage = qro.CurrentPage > qro.LastPage ? qro.LastPage : qro.CurrentPage;

                int skip = (qro.CurrentPage - 1) * qro.PageSize;
                query       = query.Skip(skip).Take(qro.PageSize);
                qro.IsPaged = true;
            }
            else
            {
                qro.CurrentPage = 1;
                qro.LastPage    = 1;
            }



            return(query);
        }