SqlBuilder 1.2

Rating: No reviews yet
Downloads: 0
Updated: Jul 7, 2009 by luizcarlosfaria
Dev status: Planning Help Icon

Available Downloads

There are no downloads associated with this release.

Release Notes

New version with fluent interfaces

Old Way

SelectSQLBuilder target = new SelectSQLBuilder(); // TODO: Initialize to an appropriate value
target.Tables.Add(new FromItem(LiteralManager.GetLiteralBuilder().BuildTableName("dataBaseName", "dbo", "tableOfView"), "con"));
target.Columns.Add(new ColumnItem(LiteralManager.GetLiteralBuilder().BuildColumnName("idOfTable")));
target.Columns.Add(new ColumnItem(LiteralManager.GetLiteralBuilder().BuildColumnName("Site"), "Nome"));
target.Columns.Add(new ColumnItem(LiteralManager.GetLiteralBuilder().BuildColumnName("columnName01")));
target.Columns.Add(new ColumnItem(LiteralManager.GetLiteralBuilder().BuildColumnName("columnName02")));

OrBinaryOperator orBinaryOperator = new OrBinaryOperator(
		new IsNullOperator(
			LiteralManager.GetLiteralBuilder().BuildParameter("columnName02")
		),
		new EqualToOperator(
			LiteralManager.GetLiteralBuilder().BuildColumnName("columnName02"),
			LiteralManager.GetLiteralBuilder().BuildParameter("columnName02")
		)
	);
target.WhereClause.Items.Add(orBinaryOperator);
string actual = target.ToSQL();

New Way to Write an SQL Statement

SQLBuilder target = new SQLBuilderFactory().NewSelectSQLBuilder();
SQLBuilder.AddTable("dataBaseName", "dbo", "tableOfView", "con");
SQLBuilder.AddColumn("idOfTable");
SQLBuilder.AddColumn("Site", "Nome");
SQLBuilder.AddColumn("columnName01");
SQLBuilder.AddColumn("columnName02");
SQLBuilder.Where.Add("columnName02").IsNull();
SQLBuilder.Where.Add("columnName02").AreEqualTo(SQLBuilder.Param("columnName02"));