internal OrderByItemCollection Clone()
		{
			OrderByItemCollection result = new OrderByItemCollection();
			foreach( OrderByItem item in this.InnerList )
			{
				result.Add(item); // clone item?
			}
			return result;
		}
        internal OrderByItemCollection Clone()
        {
            OrderByItemCollection result = new OrderByItemCollection();

            foreach (OrderByItem item in this.InnerList)
            {
                result.Add(item);                 // clone item?
            }
            return(result);
        }
Example #3
0
        public OrderBy Parse(Type type, string expression)
        {
            // Example expressions for an Employee query:
            // "FirstName, LastName"
            // "FirstName ASC, LastName DESC"
            // "Company.Name"
            // "Company.Name ASC"
            // "Company.Address.State ASC"
            // "Company.Name ASC, Company.Address.State ASC, FirstName ASC"
            // "Company.Name ASC, HomeAddress.ZipCode, Company.Address.State DESC, ZipCode"

            _expression = expression;

            EntityMap entity = _maps[type];

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

            OrderByItemCollection items = new OrderByItemCollection();
            OrderByJoinCollection joins = new OrderByJoinCollection();

            using (StringReader reader = new StringReader(expression))
            {
                OPathLexer lexer = new OPathLexer(reader);

                lexer.Lex();
                while (lexer.CurrentToken != null)
                {
                    OrderByItem item = ParseItem(lexer, entity, joins, null);
                    items.Add(item);
                }

                if (lexer.LastToken != null && lexer.LastToken.Type == TokenType.COMMA)
                {
                    throw new OPathException("A trailing comma was detected in sort expression '" + expression + "'.");
                }
            }

            return(new OrderBy(null, items, joins));
        }
Example #4
0
        public OrderBy Parse(Type type, string expression)
        {
            // Example expressions for an Employee query:
            // "FirstName, LastName"
            // "FirstName ASC, LastName DESC"
            // "Company.Name"
            // "Company.Name ASC"
            // "Company.Address.State ASC"
            // "Company.Name ASC, Company.Address.State ASC, FirstName ASC"
            // "Company.Name ASC, HomeAddress.ZipCode, Company.Address.State DESC, ZipCode"

            _expression = expression;

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

            OrderByItemCollection items = new OrderByItemCollection();
            OrderByJoinCollection joins = new OrderByJoinCollection();

            using( StringReader reader = new StringReader(expression) )
            {
                OPathLexer lexer = new OPathLexer(reader);

                lexer.Lex();
                while( lexer.CurrentToken != null )
                {
                    OrderByItem item = ParseItem(lexer, entity, joins, null);
                    items.Add(item);
                }

                if( lexer.LastToken != null && lexer.LastToken.Type == TokenType.COMMA )
                {
                    throw new OPathException("A trailing comma was detected in sort expression '" + expression + "'.");
                }
            }

            return new OrderBy(null, items, joins);
        }
Example #5
0
		public OrderBy(Expression source, OrderByItemCollection orderByItems, OrderByJoinCollection orderByJoins)
		{
			this.Source = source;
			_items = orderByItems;
			_joins = orderByJoins;
		}
Example #6
0
 public OrderBy(Expression source, OrderByItemCollection orderByItems, OrderByJoinCollection orderByJoins)
 {
     this.Source = source;
     _items      = orderByItems;
     _joins      = orderByJoins;
 }