Say I want to get the same data from an SQL database, but want to have multiple ways of getting that data. For example, say I want to be able to search a database for users based on username, real name and date of birth. In my data access layer I would have GetUserByUsername(), GetUserByRealName() and GetUserByDOB(). However, when I have a lot of different ways to potentially search for a lot of different objects in the database (say, for example 15 completely unrelated objects to search for and 5 completely unique ways to search for them each) this very quickly gets messy. Is there a better way to do it?
Getting the same data in multiple ways
database
Two options immediately come to mind.A general search which returns any users with a matching attribute:GetUsersByValue(value)GetUsersByValue(1916-09-10)  -> bbrown|Bob Brown|1916-09-10, schan|Sally Chan|1916-09-10Whilst useful, this could be very inefficient, and could generate a lot of noise if you have fields which reasonably contain the same sort of data types. eg social security numbers and phone numbers.  So you might prefer:An arbitrary attribute search which returns any users matching the value of the specified attribute:GetUsersByAttribute(name, value)GetUsersByAttribute('DOB', '1916-09-10')  -> bbrown|Bob Brown|1916-09-10, schan|Sally Chan|1916-09-10