Ejemplo n.º 1
0
        public override EntitySet Load(Evaluant.NLinq.NLinqQuery query, string[] attributes, string orderby, int first, int max)
        {
            if (first <= 0)
                throw new ArgumentException("first must be greater than 0");

            if (max < 0)
                throw new ArgumentException("max must be none negative");

            XPathTransformer transformer = new XPathTransformer(Factory.Model);
            string xpath = transformer.ConvertToXPath(query);
            EntitySet result = LoadWithXPath(xpath);

            LoadAttribute(result, attributes);

            // sort
            if (orderby != null)
                result.Sort(orderby.Split(','));

            // page
            EntitySet pageResult = new EntitySet();
            Utils.TruncateList(result, pageResult, first, max);

            return pageResult;
        }
Ejemplo n.º 2
0
        public override object LoadScalar(Evaluant.OPath.OPathQuery query)
        {
            XPathTransformer transformer = new XPathTransformer(false, this.Model);
            string xpath = transformer.ConvertToXPath(query);

            object result = null;
            result = _Document.CreateNavigator().Evaluate(xpath);

            // Ensure the result in an Int32 in cas of a count()
            if (query.Expression.Operands[0] is OPath.Expressions.Function)
                result = Convert.ToInt32(result);

            return result;
        }