DynamicParameters should implement IEnumerable to support collection initializer syntax
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
This is related to https://github.com/StackExchange/Dapper/issues/849 and https://github.com/StackExchange/Dapper/issues/304 but not exactly.
Please let DynamicParameters implement IEnumerable so that it supports collection initializer syntax. It is a slightly cleaner way or registering params.
Compare:
DynamicParameters dynamicParams = new DynamicParameters();
dynamicParams.Add("@sessionId", exportSession.Id);
dynamicParams.Add("@skipValidation", exportSession.SkipValidation);
dynamicParams.Add("@result", dbType: DbType.Int32, direction: ParameterDirection.Output);
vs
DynamicParameters dynamicParams = new DynamicParameters
{
{ "@sessionId", exportSession.Id },
{ "@skipValidation", exportSession.SkipValidation },
{ "@result", dbType: DbType.Int32, direction: ParameterDirection.Output },
};
Slightly less verbose.
I understand that you need to decide on the GetEnumerator part, as to what to return. I learn that there is little hesitancy on exposing Parameters as such. Maybe even iterating over ParameterNames would do. Or else iterate over <ParameterName, obj Value>. But really it should have been <ParameterName, ParameterInfo> if you were open to it.
To consider
If iterating over ParameterNames, now we have two ways to iterate over parameter names, but I guess it is OK.
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
Start at DynamicParameters and review related issues #849 and #304 for prior discussion. Determine the intended GetEnumerator behavior and collection-initializer compatibility, then verify that the chosen parameter representation can be enumerated consistently and that the requested syntax works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100