internal OrderByJoin Clone()
		{
			OrderByJoin clone = new OrderByJoin(_relationMap);
			clone._alias = _alias;
			clone._nestedJoins = _nestedJoins.Clone();
			return clone;
		}
Exemple #2
0
        //private object _physicalInfo;

        public OrderByItem(string item, FieldMap fieldInfo, bool ascending, OrderByJoin join)
        {
            this.Item      = item;
            this.FieldInfo = fieldInfo;
            this.Ascending = ascending;
            this.Join      = join;
        }
		//private object _physicalInfo;

		public OrderByItem(string item, FieldMap fieldInfo, bool ascending, OrderByJoin join)
		{
			this.Item = item;
			this.FieldInfo = fieldInfo;
			this.Ascending = ascending;
			this.Join = join;
		}
		public int Add(OrderByJoin value)
		{
			if( this.Contains(value.Name) )
			{
				throw new ArgumentException("Object with same name already exists in collection.", "value");
			}
			return this.InnerList.Add(value);
		}
 public int Add(OrderByJoin value)
 {
     if (this.Contains(value.Name))
     {
         throw new ArgumentException("Object with same name already exists in collection.", "value");
     }
     return(this.InnerList.Add(value));
 }
Exemple #6
0
        internal OrderByJoin Clone()
        {
            OrderByJoin clone = new OrderByJoin(_relationMap);

            clone._alias       = _alias;
            clone._nestedJoins = _nestedJoins.Clone();
            return(clone);
        }
		public void Remove(OrderByJoin value)
		{
			this.InnerList.Remove(value);
		}
		public void Insert(int index, OrderByJoin value)
		{
			this.InnerList.Insert(index, value);
		}
		public void CopyTo(OrderByJoin[] array, int index)
		{
			this.CopyTo(array, index);
		}
		internal OrderByJoinCollection(OrderByJoin[] items)
		{
			this.InnerList.AddRange(items);
		}
Exemple #11
0
        private OrderByItem ParseItem(OPathLexer lexer, EntityMap entity, OrderByJoinCollection joins, OrderByJoin parentJoin)
        {
            Yytoken token = lexer.CurrentToken;

            if (token.Type != TokenType.IDENT)
            {
                throw new OPathException("'" + token.Text + "' encountered where a property or relationship was expected in sort expression '" + _expression + "'.");
            }

            string propertyName = token.Text;

            token = lexer.Lex();
            if (token == null)
            {
                FieldMap field;
                try
                {
                    field = entity.GetFieldMap(propertyName);
                }
                catch
                {
                    throw new OPathException(string.Format("The specified property '{0}' in the sort '{1}' is not defined in the entity map for type '{2}'.", propertyName, _expression, entity.Type));
                }

                return(new OrderByItem(propertyName, field, true, parentJoin));
            }
            if (token.Type != TokenType.PERIOD)
            {
                if (token.Type != TokenType.ASCEND && token.Type != TokenType.DESCEND && token.Type != TokenType.COMMA)
                {
                    throw new OPathException("'" + token.Text + "' is not valid in sort expression '" + _expression + "'.");
                }

                FieldMap field;
                try
                {
                    field = entity.GetFieldMap(propertyName);
                }
                catch
                {
                    throw new OPathException(string.Format("The specified property '{0}' in the sort '{1}' is not defined in the entity map for type '{2}'.", propertyName, _expression, entity.Type));
                }

                bool ascending = (token.Type != TokenType.DESCEND);

                if (token.Type != TokenType.COMMA)
                {
                    lexer.MoveToNext();
                }
                lexer.MoveToNext();

                return(new OrderByItem(propertyName, field, ascending, parentJoin));
            }
            else             // dot operator (.)
            {
                token = lexer.Lex();
                if (token == null)
                {
                    throw new OPathException("End of expression encountered where a property or relationship was expected in sort expression '" + _expression + "'.");
                }
                if (token.Type != TokenType.IDENT)
                {
                    throw new OPathException("'" + token.Text + "' encountered where a property or relationship was expected in sort expression '" + _expression + "'.");
                }

                RelationMap relation = entity.Relation(propertyName);
                if (relation == null)
                {
                    throw new OPathException(string.Format("The specified relationship '{0}' in the sort expression '{1}' is not defined in the entity map for type '{2}'.", propertyName, _expression, entity.Type));
                }
                if (relation.Relationship != Relationship.Parent)
                {
                    throw new Exception("Relationship '" + relation.Alias + "' is not a ManyToOne relation.  Only ManyToOne relations are allowed in sort expressions.");
                }

                EntityMap relEntity = _maps[relation.Type];

                OrderByJoin join = joins[propertyName];
                if (join == null)
                {
                    join = new OrderByJoin(relation);
                    joins.Add(join);
                }

                // recursive call
                return(ParseItem(lexer, relEntity, join.NestedJoins, join));
            }
        }
 public void Remove(OrderByJoin value)
 {
     this.InnerList.Remove(value);
 }
 public void Insert(int index, OrderByJoin value)
 {
     this.InnerList.Insert(index, value);
 }
Exemple #14
0
        private OrderByItem ParseItem(OPathLexer lexer, EntityMap entity, OrderByJoinCollection joins, OrderByJoin parentJoin)
        {
            Yytoken token = lexer.CurrentToken;
            if( token.Type != TokenType.IDENT )
            {
                throw new OPathException("'" + token.Text + "' encountered where a property or relationship was expected in sort expression '" + _expression + "'.");
            }

            string propertyName = token.Text;

            token = lexer.Lex();
            if( token == null )
            {
                FieldMap field;
                try
                {
                    field = entity.GetFieldMap(propertyName);
                }
                catch
                {
                    throw new OPathException(string.Format("The specified property '{0}' in the sort '{1}' is not defined in the entity map for type '{2}'.", propertyName, _expression, entity.Type));
                }

                return new OrderByItem(propertyName, field, true, parentJoin);
            }
            if( token.Type != TokenType.PERIOD )
            {
                if( token.Type != TokenType.ASCEND && token.Type != TokenType.DESCEND && token.Type != TokenType.COMMA )
                {
                    throw new OPathException("'" + token.Text + "' is not valid in sort expression '" + _expression + "'.");
                }

                FieldMap field;
                try
                {
                    field = entity.GetFieldMap(propertyName);
                }
                catch
                {
                    throw new OPathException(string.Format("The specified property '{0}' in the sort '{1}' is not defined in the entity map for type '{2}'.", propertyName, _expression, entity.Type));
                }

                bool ascending = (token.Type != TokenType.DESCEND);

                if( token.Type != TokenType.COMMA )
                {
                    lexer.MoveToNext();
                }
                lexer.MoveToNext();

                return new OrderByItem(propertyName, field, ascending, parentJoin);
            }
            else // dot operator (.)
            {
                token = lexer.Lex();
                if( token == null )
                {
                    throw new OPathException("End of expression encountered where a property or relationship was expected in sort expression '" + _expression + "'.");
                }
                if( token.Type != TokenType.IDENT )
                {
                    throw new OPathException("'" + token.Text + "' encountered where a property or relationship was expected in sort expression '" + _expression + "'.");
                }

                RelationMap relation = entity.Relation(propertyName);
                if( relation == null )
                {
                    throw new OPathException(string.Format("The specified relationship '{0}' in the sort expression '{1}' is not defined in the entity map for type '{2}'.", propertyName, _expression, entity.Type));
                }
                if( relation.Relationship != Relationship.Parent )
                {
                    throw new Exception("Relationship '" + relation.Alias + "' is not a ManyToOne relation.  Only ManyToOne relations are allowed in sort expressions.");
                }

                EntityMap relEntity = _maps[relation.Type];

                OrderByJoin join = joins[propertyName];
                if( join == null )
                {
                    join = new OrderByJoin(relation);
                    joins.Add(join);
                }

                // recursive call
                return ParseItem(lexer, relEntity, join.NestedJoins, join);
            }
        }