|
namespace BuildingQueriesDemo.SQL
{
internal class EmployeesSql
{
#region EmployeeQueries
internal const string GetEmployeesFromCountryUk = @"Select * from Employees where Country='UK'";
internal const string GetEmployeesFromCityLondon = @"Select * from Employees where Country='UK' AND City='London'";
#endregion
#region Query Builder Method
internal static string GetEmployees(string country, string optionalCity=null, string optionalTitleOfCourtesy=null)
{
var query = string.Format("Select * from Employees Where Country='{0}'",country);
if (!string.IsNullOrEmpty(optionalCity))
query = string.Format("{0} AND City= {1}", query, optionalCity);
if (!string.IsNullOrEmpty((optionalTitleOfCourtesy)))
query = string.Format("{0} AND titleOfCourtesy={1}", query, optionalTitleOfCourtesy);
return query;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.