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

Allow dictionaries to be passed with parameters #623

Merged

Conversation

asherber
Copy link
Collaborator

@asherber asherber commented Sep 3, 2021

We can currently pass in POCOs that hold parameter values (for queries and stored procs) and PP will turn them into arrays of parameters. This PR lets us pass in Dictionaries as well.

db.Query(sql, new { Foo = 5, Bar = "apple" });

// same as 
var dict = new Dictionary<string, object>()
{
    ["Foo"] = 5,
    ["Bar"] = "apple"
}
db.Query(sql, dict);

The reason for this is that it lets you build up a collection of arbitrarily named parameters.

@asherber asherber requested a review from pleb September 3, 2021 21:54
@pleb pleb merged commit bd7953a into CollaboratingPlatypus:development Sep 3, 2021
@iadaz
Copy link
Collaborator

iadaz commented Sep 6, 2021

I thought this was useful enough to document. I've added the missing Wiki "Querying" page just by cobbling together examples from elsewhere, and added this at the bottom under "future dev". Hope that's OK.

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

Successfully merging this pull request may close these issues.

3 participants