I have a user-input form which contains multiple user-input fields which needs to be supplied as parameters in Oracle query. As these are optional parameters and query contains "AND" in "WHERE" clause, it needs to declare many query string constant in C# class and in order to pass the parameter in query, add multiple if-else or switch cases. While it seems to work well, but it makes the code hard to manage. Is there a way to handle this situation using Query or Stored Procedure? Don't want to create queries dynamically using string operation which can give SQL vulnerability.
SomeConstant.cs
public const string Query1
public const string Query2
public const string Query3
public const string Query4
ConsumeQuery.cs
If(ConditionTrue){
Query1;
}
else if(ConditionTrue)
{
Query3;
}
and so on.......