Esempio n. 1
0
		public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
		{
			SqlStatementKind kind = Target.BuildSql(b, context);
			if (kind == SqlStatementKind.SelectOrderBy)
				WrapSqlIntoNestedStatement(b, context);
			
			b.Append(" ORDER BY ");
			
			for (int i = 0; i < arguments.Count; i++) {
				StringWriter w = new StringWriter();
				ExpressionSqlWriter writer = new ExpressionSqlWriter(w, context, arguments[i].Argument.Parameters[0]);
				writer.Write(arguments[i].Argument.Body);
				
				if (i == 0)
					b.Append(w.ToString());
				else
					b.Append(", " + w.ToString());
				
				if (arguments[i].Descending)
					b.Append(" DESC");
				else
					b.Append(" ASC");
			}
			
			return SqlStatementKind.SelectOrderBy;
		}
Esempio n. 2
0
        static void BuildSqlForCondition(StringBuilder b, SqlQueryContext context, LambdaExpression condition)
        {
            Debug.Assert(condition.Parameters.Count == 1);
            StringWriter        w      = new StringWriter(CultureInfo.InvariantCulture);
            ExpressionSqlWriter writer = new ExpressionSqlWriter(w, context, condition.Parameters[0]);

            writer.Write(condition.Body);
            b.Append(w.ToString());
        }
Esempio n. 3
0
        public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
        {
            SqlStatementKind kind = Target.BuildSql(b, context);

            if (kind == SqlStatementKind.SelectOrderBy)
            {
                WrapSqlIntoNestedStatement(b, context);
            }

            b.Append(" ORDER BY ");

            for (int i = 0; i < arguments.Count; i++)
            {
                StringWriter        w      = new StringWriter();
                ExpressionSqlWriter writer = new ExpressionSqlWriter(w, context, arguments[i].Argument.Parameters[0]);
                writer.Write(arguments[i].Argument.Body);

                if (i == 0)
                {
                    b.Append(w.ToString());
                }
                else
                {
                    b.Append(", " + w.ToString());
                }

                if (arguments[i].Descending)
                {
                    b.Append(" DESC");
                }
                else
                {
                    b.Append(" ASC");
                }
            }

            return(SqlStatementKind.SelectOrderBy);
        }
Esempio n. 4
0
		static void BuildSqlForCondition(StringBuilder b, SqlQueryContext context, LambdaExpression condition)
		{
			Debug.Assert(condition.Parameters.Count == 1);
			StringWriter w = new StringWriter(CultureInfo.InvariantCulture);
			ExpressionSqlWriter writer = new ExpressionSqlWriter(w, context, condition.Parameters[0]);
			writer.Write(condition.Body);
			b.Append(w.ToString());
		}