Skip to content

Commit

Permalink
Chain Where to a WhereList
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Sep 10, 2016
1 parent 9060a40 commit 4df4472
Showing 1 changed file with 192 additions and 1 deletion.
193 changes: 192 additions & 1 deletion dg.Sql/Sql/QueryKeywords/Where.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public Where(WhereCondition condition, IPhrase phrase)
FirstType = ValueObjectType.Value;
Comparison = WhereComparison.None;
}

public Where(WhereCondition condition, IPhrase phrase, WhereComparison comparison, object value)
{
Condition = condition;
Expand Down Expand Up @@ -304,6 +304,8 @@ public Where(WhereCondition condition, IPhrase phrase, WhereComparison compariso
SecondType = ValueObjectType.ColumnName;
}

#region Builders

public void BuildCommand(StringBuilder outputBuilder, bool isFirst, ConnectorBase conn, Query relatedQuery)
{
BuildCommand(outputBuilder, isFirst, conn, relatedQuery, null, null);
Expand Down Expand Up @@ -626,5 +628,194 @@ public void BuildCommand(StringBuilder outputBuilder, bool isFirst, ConnectorBas
}
}
}

#endregion

#region Chainable

public WhereList AND(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(thisObject, thisObjectType, comparison, thatObject, thatObjectType);
}

public WhereList AND(string columnName, object columnValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(columnName, columnValue);
}

public WhereList AND(string columnName, WhereComparison comparison, object columnValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(columnName, comparison, columnValue);
}

public WhereList AND(string literalExpression)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(literalExpression);
}

public WhereList AND(IPhrase phrase)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(phrase);
}

public WhereList AND(IPhrase phrase, WhereComparison comparison, object value)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(phrase, comparison, value);
}

public WhereList AND(IPhrase phrase, WhereComparison comparison, object value, ValueObjectType valueType)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(phrase, comparison, value, valueType);
}

public WhereList AND(IPhrase phrase, WhereComparison comparison, string tableName, string columnName)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(phrase, comparison, tableName, columnName);
}

public WhereList AND(WhereList whereList)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(whereList);
}

public WhereList AND(string tableName, string columnName, WhereComparison comparison, object columnValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(tableName, columnName, comparison, columnValue);
}

public WhereList AND(string tableName, string columnName, WhereComparison comparison, string otherTableName, string otherColumnName)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(tableName, columnName, comparison, otherTableName, otherColumnName);
}

public WhereList AND(string tableName, string columnName, object betweenValue, object andValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(tableName, columnName, betweenValue, andValue);
}

public WhereList AND(string columnName, object betweenValue, object andValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(columnName, betweenValue, andValue);
}

public WhereList OR(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(thisObject, thisObjectType, comparison, thatObject, thatObjectType);
}

public WhereList OR(string columnName, object columnValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(columnName, columnValue);
}

public WhereList OR(string columnName, WhereComparison comparison, object columnValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(columnName, comparison, columnValue);
}

public WhereList OR(string literalExpression)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(literalExpression);
}

public WhereList OR(IPhrase phrase)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(phrase);
}

public WhereList OR(IPhrase phrase, WhereComparison comparison, object value)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(phrase, comparison, value);
}

public WhereList OR(IPhrase phrase, WhereComparison comparison, object value, ValueObjectType valueType)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(phrase, comparison, value, valueType);
}

public WhereList OR(IPhrase phrase, WhereComparison comparison, string tableName, string columnName)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(phrase, comparison, tableName, columnName);
}

public WhereList OR(WhereList whereList)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(whereList);
}

public WhereList OR(string tableName, string columnName, WhereComparison comparison, object columnValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(tableName, columnName, comparison, columnValue);
}

public WhereList OR(string tableName, string columnName, WhereComparison comparison, string otherTableName, string otherColumnName)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(tableName, columnName, comparison, otherTableName, otherColumnName);
}

public WhereList OR(string tableName, string columnName, object betweenValue, object andValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(tableName, columnName, betweenValue, andValue);
}

public WhereList OR(string columnName, object betweenValue, object andValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(columnName, betweenValue, andValue);
}

#endregion

}
}

0 comments on commit 4df4472

Please sign in to comment.