예제 #1
0
        internal Expression Parse(Type type, string query, string sort, out int paramCount)
        {
            EntityMap map = _maps[type];

            if (map == null)
            {
                throw new Exception("Type " + type + " does not have an entity mapping defined to the database.");
            }

            // get the expression tree from the parser
            Expression expr = new OPathParser().ParseObjectQuery(type, query, true, out paramCount);

            // wrap expression in an OrderBy node, if a sort order was specified
            if (sort != null && sort.Length > 0)
            {
                OrderBy orderBy = new OPathSortParser(_maps).Parse(type, sort);
                orderBy.Source = expr;
                expr           = orderBy;
            }

#if DEBUG_PARSER
            Debug.WriteLine("\n\nEXP: " + query);
            Debug.WriteLine("\nRAW PARSER TREE:\n" + expr.ToXmlString());
#endif

            // fix problems with the tree generated by the parser, normalizing the trees for equivalent expressions
            FixTree(expr);

#if DEBUG_PARSER
            Debug.WriteLine("\n\nEXP: " + query);
            Debug.WriteLine("\nFINAL EXPRESSION TREE:\n" + expr.ToXmlString());
#endif

            Validate(expr);

            return(expr);
        }
예제 #2
0
		internal Expression Parse(Type type, string query, string sort, out int paramCount)
		{
			EntityMap map = _maps[type];
			if( map == null )
			{
				throw new Exception("Type " + type + " does not have an entity mapping defined to the database.");
			}

			// get the expression tree from the parser
			Expression expr = new OPathParser().ParseObjectQuery(type, query, true, out paramCount);

			// wrap expression in an OrderBy node, if a sort order was specified
			if( sort != null && sort.Length > 0 )
			{
				OrderBy orderBy = new OPathSortParser(_maps).Parse(type, sort);
				orderBy.Source = expr;
				expr = orderBy;
			}

#if DEBUG_PARSER
			Debug.WriteLine("\n\nEXP: " + query);
			Debug.WriteLine("\nRAW PARSER TREE:\n" + expr.ToXmlString());
#endif

			// fix problems with the tree generated by the parser, normalizing the trees for equivalent expressions
			FixTree(expr);

#if DEBUG_PARSER
			Debug.WriteLine("\n\nEXP: " + query);
			Debug.WriteLine("\nFINAL EXPRESSION TREE:\n" + expr.ToXmlString());
#endif

			Validate(expr);

			return expr;
		}