Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters are not working #683

Open
AaronSadlerUK opened this issue Mar 15, 2023 · 5 comments
Open

Parameters are not working #683

AaronSadlerUK opened this issue Mar 15, 2023 · 5 comments

Comments

@AaronSadlerUK
Copy link

AaronSadlerUK commented Mar 15, 2023

Version: NPoco 5.3.2

I'm using the sqlBuilder with a template as follows:

var template = sqlBuilder.AddTemplate($"select * from TABLE WHERE /**where**/");

followed by:

sqlBuilder.Where("COLUMN LIKE @0 OR COLUMN2 LIKE @0", new[]{ searchProperties.Keywords });

I can see in my breakpoint that searchProperties.Keywords does indeed have a value, however I get the following exception:

ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Parameter '@0' specified but only 0 parameters supplied

When I look at the raw SQL generated I can see that @0 has not been replaced.

Is this a known bug, or am I doing something wrong here?

Thanks for all your help!

@schotime
Copy link
Owner

What is the type of Keywords?

@AaronSadlerUK
Copy link
Author

It is a string, i have also tried with int in other where statements with the same issue

@schotime
Copy link
Owner

What if you try this?

sqlBuilder.Where("COLUMN LIKE @0 OR COLUMN2 LIKE @0", searchProperties.Keywords);

@AaronSadlerUK
Copy link
Author

I tried that prior, I tried explicitly setting the array in case that was the issue.

It returns the same exception that no parameters are set, even though they are

@schotime
Copy link
Owner

You'll need to post a full sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants