Add indexer to DynamicParameters so that C# 7 dictionary initializer syntax can be used
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
I've got some code that looks like this:
public class MyDynamicParameters : DynamicParameters {
public object this[string key] {
set => Add(key, value);
}
}
Which lets MyDynamicParameters be initialized like this:
new MyDynamicParameters() {
["Id"] = 1,
[Constants.MySpParamName] = "test",
}
It would be nice if this indexer setter could be introduced to DynamicParameters to make initializing this object quite clean, over a list of parameters.Add(key, value) calls.
I can take a shot at implementing this if you want - just let me know and I'll make a PR. One question if I do though: should I modify the SqlMapper.IParameterLookup.this[object name] interface member to include a setter (might be breaking for those who have implemented this?)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate DynamicParameters and the SqlMapper.IParameterLookup interface, then read how parameter names and values are currently added and exposed. Check the existing tests around DynamicParameters before deciding how the setter should interact with the interface. Done means C# 7 dictionary initializer assignments work without breaking existing implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- database
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100