Skip to content

Instantly share code, notes, and snippets.

@remzmike
Created June 21, 2017 19:57
Show Gist options
  • Save remzmike/e41e831670dad3fbe1b5330083af9514 to your computer and use it in GitHub Desktop.
Save remzmike/e41e831670dad3fbe1b5330083af9514 to your computer and use it in GitHub Desktop.
60 second where clause builder
// 60 second where clauses
string Or(string a, string b)
{
return "( " + a + " OR " + b + " )";
}
string And(string a, string b)
{
return "( " + a + " AND " + b + " )";
}
string Eq(string a, string b)
{
return "( " + a + " = " + b + " )";
}
void Main()
{
// code like this
var s = Or(
And(
Eq("A","@A0"),
Eq("B","@B0")
),
And(
Eq("A","@A1"),
Eq("B","@B1")
)
);
Console.WriteLine(s);
// that makes a string like this
//(NPA = @NPA0 and NXX = @NXX0) OR (NPA = @NPA1 and NXX = @NXX1)
}
// Define other methods and classes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment