Example #1
0
        /// <summary>
        /// Adds the given modifier to the SELECT query
        /// </summary>
        public RDFSelectQuery AddModifier(RDFModifier modifier)
        {
            if (modifier != null)
            {
                //Ensure to have only one distinct modifier in the query
                if (modifier is RDFDistinctModifier && this.Modifiers.Any(m => m is RDFDistinctModifier))
                {
                    return(this);
                }
                //Ensure to have only one limit modifier in the query
                if (modifier is RDFLimitModifier && this.Modifiers.Any(m => m is RDFLimitModifier))
                {
                    return(this);
                }
                //Ensure to have only one offset modifier in the query
                if (modifier is RDFOffsetModifier && this.Modifiers.Any(m => m is RDFOffsetModifier))
                {
                    return(this);
                }

                //Add the modifier, avoiding duplicates
                if (!this.Modifiers.Exists(m => m.Equals(modifier)))
                {
                    this.Modifiers.Add(modifier);
                }
            }
            return(this);
        }
Example #2
0
        /// <summary>
        /// Adds the given modifier to the query
        /// </summary>
        public RDFSelectQuery AddModifier(RDFModifier modifier)
        {
            if (modifier != null)
            {
                //Ensure to have only one distinct modifier in the query
                if (modifier is RDFDistinctModifier && this.GetModifiers().Any(m => m is RDFDistinctModifier))
                {
                    return(this);
                }
                //Ensure to have only one limit modifier in the query
                if (modifier is RDFLimitModifier && this.GetModifiers().Any(m => m is RDFLimitModifier))
                {
                    return(this);
                }
                //Ensure to have only one offset modifier in the query
                if (modifier is RDFOffsetModifier && this.GetModifiers().Any(m => m is RDFOffsetModifier))
                {
                    return(this);
                }
                //Ensure to have only one orderby modifier per variable in the query
                if (modifier is RDFOrderByModifier && this.GetModifiers().Any(m => m is RDFOrderByModifier && ((RDFOrderByModifier)m).Variable.Equals(((RDFOrderByModifier)modifier).Variable)))
                {
                    return(this);
                }

                //Add the modifier, avoiding duplicates
                if (!this.GetModifiers().Any(m => m.Equals(modifier)))
                {
                    this.QueryMembers.Add(modifier);
                }
            }
            return(this);
        }