I want to write a method having four input parameters,all the input parameters are not mandatory. I need to check whether the input parameter is not null and query the database to return the result. Is der any way to do this without checking for all possible combinations… Its like a search engine.. If u give all the input parameters it will give u the exact result else nearest possible result.
For eg,
input(city,customer,name,zip)
if zip is not equal to null and all other fields are null query the database and return values corresponding to zip. It will be list of customers in the entire area based on the zip.If all the fields are present it will give the exact result. I know that i can check each value and write the query in a conditional loop for all possible combinations to get the result. But i think its a dirty fix..
Thanks..
Instead of examining all the possible combinations, compose your query dynamically: