Inheritance: ICloneable
Exemplo n.º 1
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);
		}
Exemplo n.º 2
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);
			}
		}
Exemplo n.º 3
0
		public void Reinitialize()
		{
			_selectQuery = InitialQuery;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Clones the SelectQuery
		/// </summary>
		/// <returns>A new instance of SelectQuery which is exactly the same as the current one.</returns>
		public SelectQuery Clone()
		{
			var newQuery = new SelectQuery
			               	{
			               		columns = new SelectColumnCollection(columns),
			               		orderByTerms = new OrderByTermCollection(orderByTerms),
			               		groupByTerms = new GroupByTermCollection(groupByTerms),
			               		wherePhrase = wherePhrase.Clone(),
			               		fromClause = fromClause.Clone(),
			               		top = top,
			               		distinct = distinct,
			               		tableSpace = tableSpace,
			               		parameters = new ParameterCollection(parameters)
			               	};

			var newSettings = new PageSettings {PageIndex = pageSettings.PageIndex, PageSize = pageSettings.PageSize};
			newQuery.pageSettings = newSettings;
			return newQuery;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Creates a FromTerm which represents a sub-query.
		/// </summary>
		/// <param name="query">A SelectQuery instance representing the sub query</param>
		/// <param name="alias">term alias</param>
		/// <returns>A FromTerm which represents a sub-query.</returns>
		public static FromTerm SubQuery(SelectQuery query, string alias)
		{
			FromTerm term = new FromTerm();
			term.expr = query;
			term.alias = alias;
			term.type = FromTermType.SubQueryObj;
			return term;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Creates a SqlExpression which represents a subquery.
		/// </summary>
		/// <param name="query">A SelectQuery object</param>
		/// <returns>A new SqlExpression</returns>
		public static SqlExpression SubQuery(SelectQuery query)
		{
			SqlExpression expr = new SqlExpression();
			expr.val = query;
			expr.type = SqlExpressionType.SubQueryObject;
			return expr;
		}
Exemplo n.º 7
0
		public void RetrieveEntity()
		{
			var query = new SelectQuery(typeof (Request));
			IEntity entity = DataPortal.Instance.Retrieve(typeof (Request), 1);
			Assert.AreEqual(1, (entity as Request).ID);
		}
Exemplo n.º 8
0
		public void RetrieveCount()
		{
			var query = new SelectQuery(typeof (Request));
			Assert.AreEqual(0, DataPortal.Instance.RetrieveCount(query));
		}
Exemplo n.º 9
0
		public void RetrieveAllWithoutType()
		{
			var query = new SelectQuery(typeof (Request));
			IList requests = DataPortal.Instance.Retrieve(query);
			CollectionAssert.IsNotEmpty(requests);
		}
Exemplo n.º 10
0
		public void RetrieveAll()
		{
			var query = new SelectQuery(typeof (Request));
			List<Request> requests = DataPortal.Instance.Retrieve<Request>(query);
			CollectionAssert.IsNotEmpty(requests);
		}