Example #1
0
			/// <summary>
			/// 初始化一个新 <see cref="SqlJoinClause" /> 实例。
			/// </summary>
			/// <param name="sql">SQL 生成器</param>
			public SqlJoinClause(Sql sql)
			{
				_sql = sql;
			}
Example #2
0
		static bool Is(Sql sql, string sqltype)
		{
			return sql != null && sql._sql != null && sql._sql.StartsWith(sqltype, StringComparison.InvariantCultureIgnoreCase);
		}
Example #3
0
		private void Build(StringBuilder sb, List<object> args, Sql lhs)
		{
			if(!String.IsNullOrEmpty(_sql))
			{
				// Add SQL to the string
				if(sb.Length > 0)
				{
					sb.Append("\n");
				}

				var sql = ParametersHelper.ProcessParams(_sql, _args, args);

				if(Is(lhs, "WHERE ") && Is(this, "WHERE "))
					sql = "AND " + sql.Substring(6);
				if(Is(lhs, "ORDER BY ") && Is(this, "ORDER BY "))
					sql = ", " + sql.Substring(9);

				sb.Append(sql);
			}

			// Now do rhs
			if(_rhs != null)
				_rhs.Build(sb, args, this);
		}
Example #4
0
		/// <summary>
		/// 添加另一个 SQL 生成器到当前的 SQL 生成器
		/// </summary>
		/// <param name="sql">要添加的 SQL 生成器</param>
		/// <returns>合并后的 SQL 生成器</returns>
		public Sql Append(Sql sql)
		{
			if(_rhs != null)
				_rhs.Append(sql);
			else
				_rhs = sql;

			return this;
		}