Skip to content

Instantly share code, notes, and snippets.

@Dillie-O
Last active December 17, 2015 22:08
Show Gist options
  • Save Dillie-O/5679296 to your computer and use it in GitHub Desktop.
Save Dillie-O/5679296 to your computer and use it in GitHub Desktop.
Refactored SearchParameter dictionary declaration
// All site search criteria in a dictionary for easy lookup/manipulation
// when dynamically building the query.
public static Dictionary<string, SearchParameter> GetSearchCriteria()
{
var results = new Dictionary<string, SearchParameter>
{
{
"SiteID", new SearchParameter
{
VariableName = "site_uid",
ParameterType = typeof(string),
WhereClause = "(it.site_uid LIKE {0})",
IsWildcardSearch = true
}
},
{
"SiteName", new SearchParameter
{
VariableName = "site_name",
ParameterType = typeof(string),
WhereClause = "(it.site_name LIKE {0})",
IsWildcardSearch = true
}
},
{
"MarketName", new SearchParameter
{
VariableName = "market_name",
ParameterType = typeof(string),
WhereClause = "(it.market_name = {0})",
AllowsMultipleValues = true
}
},
{
"SiteClassDesc", new SearchParameter
{
VariableName = "site_class_desc",
ParameterType = typeof(string),
WhereClause = "(it.site_class_desc = {0})",
AllowsMultipleValues = true
}
},
{
"SiteStatusDesc", new SearchParameter
{
VariableName = "site_status_desc",
ParameterType = typeof(string),
WhereClause = "(it.site_class_desc = {0})",
AllowsMultipleValues = true
}
},
{
"SiteOnlineFrom", new SearchParameter
{
VariableName = "SiteOnlineFrom",
ParameterType = typeof(DateTime),
WhereClause = "(it.site_online_date >= {0})"
}
},
{
"SiteOnlineTo", new SearchParameter
{
VariableName = "SiteOnlineTo",
ParameterType = typeof(DateTime),
WhereClause = "(it.site_online_date <= {0})"
}
},
{
"SiteOnlineRange", new SearchParameter
{
VariableName = "SiteOnlineRange",
ParameterType = typeof(DateTime),
WhereClause = "(it.site_online_date >= {0} AND it.site_online_date <= {1})",
IsRangeSearch = true
}
},
{
"SiteOnlineStatusYN", new SearchParameter
{
VariableName = "SiteOnlineStatusYN",
ParameterType = typeof(Boolean),
WhereClause = "(it.site_online_status_yn = {0})"
}
}
};
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment