employees snippet: parameterize PopulateSales SQL (follow-up to #12524) - #13072
Merged
Merged
Conversation
Follow-up to PR dotnet#12524 (review comment on employees.cs). The PopulateSales method concatenated the `EmployeeId` cell value into a `SELECT ... WHERE EmployeeId = ` literal, so an untrusted cell value could produce SQL injection. Use a SqlParameter and a matching `@EmployeeId` placeholder instead. The parameterless `Populate` overload is kept for the existing call sites; a new `params SqlParameter[]` overload backs the parameterized call and forwards to the same connection/adapter path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ef73ba66-2734-45b8-ab5b-243681f0e519
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review comments remain, and the query is parameterized.
Pull request overview
Updates the employees WinForms snippet to parameterize the sales query while preserving existing callers.
Changes:
- Adds a
SqlParameter[]overload forPopulate. - Replaces employee ID SQL concatenation with a parameterized query.
File summaries
| File | Description |
|---|---|
snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs |
Adds parameter support and secures the sales query. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The employees.cs snippet had no project file, so touching it fails the Snippets 5000 pipeline with CS0234/CS0246 for the System.Windows.Forms and System.Data.SqlClient types it references. Add a net10.0-windows project mirroring the sibling DataGridView\BeginEdit project, plus a System.Data.SqlClient PackageReference. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ef73ba66-2734-45b8-ab5b-243681f0e519
gewarren
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR description is AI-generated.
Follow-up to #12524 (review comment gewarren on
employees.cs).Replaces the
" + employeeIdconcatenation inPopulateSaleswith aSqlParameter. Adds aparams SqlParameter[]overload ofPopulateso the existing parameterless callers keep working.Internal previews
Build report