public bool Equals(Query query)
        {
            if (query == null) return false;

            //TODO: more complicated implementation?
            return string.Equals(_originalQuery, query._originalQuery, StringComparison.Ordinal);
        }
Exemple #2
0
        public static Query Parse(string query)
        {
            var q = new Query();

            if (string.IsNullOrWhiteSpace(query)) return q;

            var lastStart = query.Length;

            //iterate in reverse because need to know where next clause ends to pull body
            for (var i = _clausesInOrder.Length - 1; i >= 0; i--)
            {
                var clause = _clausesInOrder[i];
                var parsed = ParseClause(clause, query, 0, ref lastStart);

                switch(clause)
                {
                    case select:
                        q.Select = parsed;
                        break;
                    case where:
                        q.Where = parsed;
                        break;
                    case groupBy:
                        q.GroupBy = parsed;
                        break;
                    case pivot:
                        q.Pivot = parsed;
                        break;
                    case orderBy:
                        q.OrderBy = parsed;
                        break;
                    case limit:
                        q.Limit = ParseNullableInt32(parsed);
                        break;
                    case offset:
                        q.Offset = ParseNullableInt32(parsed);
                        break;
                    case label:
                        q.Label = parsed;
                        break;
                    case format:
                        q.Format = parsed;
                        break;
                    case options:
                        q.Options = parsed;
                        break;

                }
            }

            return q;
        }