Exemple #1
0
        private Func <Triple, bool> Comparator(QueryUnit value)
        {
            var input = new JValue(value.Value);

            switch (value.Operator)
            {
            case "gt":
                return((Triple x) =>
                {
                    var jValue = x.Object.ToTypedJSON();
                    return (jValue.CompareTo(input) > 0);
                });

            case "ge":
                return((Triple x) =>
                {
                    var jValue = x.Object.ToTypedJSON();
                    return (jValue.CompareTo(input) >= 0);
                });

            case "lt":
                return((Triple x) =>
                {
                    var jValue = x.Object.ToTypedJSON();
                    return (jValue.CompareTo(input) < 0);
                });

            case "le":
                return((Triple x) =>
                {
                    var jValue = x.Object.ToTypedJSON();
                    return (jValue.CompareTo(input) <= 0);
                });

            case "contains":
                return((Triple x) =>
                {
                    var jValue = x.Object.ToValue();
                    return jValue.Contains(value.Value.ToString());
                });

            default:
                throw _storeErrors.UnknownComparator;
            }
        }
Exemple #2
0
        private IEnumerable <Triple> CreateConstraint(IStoreGraph graph, string key, QueryUnit value, Triple continuation)
        {
            var input = new JValue(value.Value);

            switch (value.Operator)
            {
            case "eq":
                return(graph.PO(key, TripleObject.FromData(value.Value.ToString()), continuation));

            case "gt":
            case "ge":
            case "lt":
            case "le":
            case "contains":
                return(graph.P(key, continuation).Where(Comparator(value)));

            default:
                throw _storeErrors.UnknownComparator;
            }
        }
Exemple #3
0
        private IEnumerable <Triple> ApplyConstraint(IEnumerable <Triple> rsp, IGraph graph, string key, QueryUnit value)
        {
            var input = new JValue(value.Value);

            switch (value.Operator)
            {
            case "eq":
                return(rsp.Where(x => graph.Exists(x.Subject, key, TripleObject.FromData(value.Value.ToString()))));

            case "gt":
            case "ge":
            case "lt":
            case "le":
            case "contains":
                return(rsp.Where((x) => {
                    var t = graph.SP(x.Subject, key).Any(Comparator(value));
                    return t;
                }));

            default:
                throw _storeErrors.UnknownComparator;
            }
        }