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

Any difference between :param and @param? #825

Closed
h1112918 opened this issue Oct 16, 2015 · 1 comment
Closed

Any difference between :param and @param? #825

h1112918 opened this issue Oct 16, 2015 · 1 comment

Comments

@h1112918
Copy link

@h1112918 h1112918 commented Oct 16, 2015

There are two ways to add parameters:

command.CommandText = "SELECT * FROM mytable WHERE Id = :Id";
command.Parameters.AddWithValue("Id", id);

and

command.CommandText = "SELECT * FROM mytable WHERE Id = @Id";
command.Parameters.AddWithValue("@Id", id);

Is there any difference in both methods in performance or something else? I also think the difference (if any) should be mentioned in the project Wiki.

@roji
Copy link
Member

@roji roji commented Oct 16, 2015

There are no differences whatsoever between the two, Npgsql parses the command text and replaces them with PostgreSQL's native parameter placeholders, which are positional and not named ($1, $2).

@roji roji closed this Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.