Inheritance: ICloneable
		/// <summary>
		///   Copies the elements of an array to the end of the <see cref='WhereClauseCollection'/>.
		/// </summary>
		/// <param name='val'>
		///    An array of type <see cref='WhereClause'/> containing the objects to add to the collection.
		/// </param>
		/// <seealso cref='WhereClauseCollection.Add'/>
		public void AddRange(WhereClause[] val)
		{
			for (int i = 0; i < val.Length; i++)
			{
				Add(val[i]);
			}
		}
Ejemplo n.º 2
0
		public void AppendSimpleSearchPattern(SelectQuery selectQuery)
		{
			var groupName = new WhereClause(WhereClauseRelationship.And);
			var groupDescription = new WhereClause(WhereClauseRelationship.And);

			string[] words = StringUtils.SmartSplit(SearchPattern);

			AppendLikeExpression(words, selectQuery, groupName, "Name");
			AppendLikeExpression(words, selectQuery, groupDescription, "Description");

			var group = new WhereClause(WhereClauseRelationship.Or);

			group.SubClauses.Add(groupName);
			group.SubClauses.Add(groupDescription);

			selectQuery.WherePhrase.SubClauses.Add(group);
		}
Ejemplo n.º 3
0
		private void AppendLikeExpression(string[] words, SelectQuery selectQuery, WhereClause group, string columnName)
		{
			foreach (string word in words)
			{
				if (word.Length == 0)
				{
					continue;
				}

				var parameter = new Parameter("%" + word + "%");
                

				group.Terms.Add(
					WhereTerm.CreateCompare(SqlExpression.Field(columnName, selectQuery.FromClause.BaseTable),
					                        SqlExpression.Parameter(), CompareOperator.Like));

				selectQuery.Parameters.Add(parameter);
			}
		}
		/// <summary>
		///   Adds a <see cref='WhereClause'/> with the specified value to the 
		///   <see cref='WhereClauseCollection'/>.
		/// </summary>
		/// <param name='val'>The <see cref='WhereClause'/> to add.</param>
		/// <returns>The index at which the new element was inserted.</returns>
		/// <seealso cref='WhereClauseCollection.AddRange'/>
		public int Add(WhereClause val)
		{
			return List.Add(val);
		}
		/// <summary>
		///   Removes a specific <see cref='WhereClause'/> from the <see cref='WhereClauseCollection'/>.
		/// </summary>
		/// <param name='val'>The <see cref='WhereClause'/> to remove from the <see cref='WhereClauseCollection'/>.</param>
		/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
		public void Remove(WhereClause val)
		{
			List.Remove(val);
		}
		/// <summary>
		///   Initializes a new instance of <see cref='WhereClauseCollection'/> containing any array of <see cref='WhereClause'/> objects.
		/// </summary>
		/// <param name='val'>
		///       A array of <see cref='WhereClause'/> objects with which to intialize the collection
		/// </param>
		public WhereClauseCollection(WhereClause[] val)
		{
			AddRange(val);
		}
		/// <summary>
		///   Inserts a <see cref='WhereClause'/> into the <see cref='WhereClauseCollection'/> at the specified index.
		/// </summary>
		/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
		/// <param name='val'>The <see cref='WhereClause'/> to insert.</param>
		/// <seealso cref='WhereClauseCollection.Add'/>
		public void Insert(int index, WhereClause val)
		{
			List.Insert(index, val);
		}
		/// <summary>
		///    Returns the index of a <see cref='WhereClause'/> in 
		///       the <see cref='WhereClauseCollection'/>.
		/// </summary>
		/// <param name='val'>The <see cref='WhereClause'/> to locate.</param>
		/// <returns>
		///   The index of the <see cref='WhereClause'/> of <paramref name='val'/> in the 
		///   <see cref='WhereClauseCollection'/>, if found; otherwise, -1.
		/// </returns>
		/// <seealso cref='WhereClauseCollection.Contains'/>
		public int IndexOf(WhereClause val)
		{
			return List.IndexOf(val);
		}
		/// <summary>
		///   Copies the <see cref='WhereClauseCollection'/> values to a one-dimensional <see cref='Array'/> instance at the 
		///    specified index.
		/// </summary>
		/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='WhereClauseCollection'/>.</param>
		/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
		/// <exception cref='ArgumentException'>
		///   <para><paramref name='array'/> is multidimensional.</para>
		///   <para>-or-</para>
		///   <para>The number of elements in the <see cref='WhereClauseCollection'/> is greater than
		///         the available space between <paramref name='arrayIndex'/> and the end of
		///         <paramref name='array'/>.</para>
		/// </exception>
		/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
		/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
		/// <seealso cref='Array'/>
		public void CopyTo(WhereClause[] array, int index)
		{
			List.CopyTo(array, index);
		}
		/// <summary>
		///   Gets a value indicating whether the 
		///    <see cref='WhereClauseCollection'/> contains the specified <see cref='WhereClause'/>.
		/// </summary>
		/// <param name='val'>The <see cref='WhereClause'/> to locate.</param>
		/// <returns>
		/// <see langword='true'/> if the <see cref='WhereClause'/> is contained in the collection; 
		///   otherwise, <see langword='false'/>.
		/// </returns>
		/// <seealso cref='WhereClauseCollection.IndexOf'/>
		public bool Contains(WhereClause val)
		{
			return List.Contains(val);
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Creates a copy of this WhereClause
		/// </summary>
		/// <returns>A new WhereClause which is exactly the same as the current one</returns>
		public WhereClause Clone()
		{
			WhereClause a = new WhereClause();

			a.relationship = relationship;
			a.whereTerms = new WhereTermCollection(whereTerms);
			foreach (WhereClause group in clauses)
			{
				a.clauses.Add(group.Clone());
			}
			return a;
		}