I am doing a enhancement job to my code. There are arrays of parameter that are passing into my methods. And those arrays of parameters are being passed into SQL query to fetch data.
For preventing the possible SQL injection, I decide to use the SqlParameter
way to handle with the those parameters. For passing the string[]
type parameters, this post works well and solve my issue.
But I do have a special method that accept Xobject[]
as the parameter. For example:
public void GetDetails(CarModel[] carModels)
{
query = "Select [MAKE],[YEAR] IN [FAKEDB].[FAKETABLE] WHERE [MAKE] " +
"IN (*carModels makes here *) AND [YEAR] IN (*carModels years here*)"
}
Assume both Make
and Year
are string type. Is it possible I can still use SQLparameter
as the solution to this method?