Skip to content

Generic Add Method for Dynamic Parameters#963

Open
roend83 wants to merge 4 commits intoDapperLib:mainfrom
roend83:dynamic-parameters-generic-add
Open

Generic Add Method for Dynamic Parameters#963
roend83 wants to merge 4 commits intoDapperLib:mainfrom
roend83:dynamic-parameters-generic-add

Conversation

@roend83
Copy link
Copy Markdown

@roend83 roend83 commented Mar 7, 2018

Addresses #958

@NickCraver
Copy link
Copy Markdown
Member

Unfortunately this would be a breaking change. While we can add the generic versions, removing the previous ones is not an option until the next major release. Can you please add them back and a test that shows these fixing the issue?

@roend83
Copy link
Copy Markdown
Author

roend83 commented Mar 7, 2018

We actually noticed an issue with the missing non-generic Add methods and added them back.

I'm fine adding a test for the generic methods. Can you tell me what I have to do to run the tests?

@NickCraver
Copy link
Copy Markdown
Member

@roend83 Ah yes, git is just doing a horrible job of diffing here - to run the tests just push :) Take advantage of the build server running them for you on this PR :)

@roend83
Copy link
Copy Markdown
Author

roend83 commented Mar 10, 2018

@NickCraver I added a couple tests that call the 2 new generic methods. Let me know if these look ok.

@NickCraver NickCraver requested a review from mgravell March 30, 2018 00:48
Copy link
Copy Markdown
Member

@NickCraver NickCraver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me, poking @mgravell for eyes as well.

{
Name = name,
Value = value,
Type = value?.GetType() ?? typeof(T),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this should be typeof(T) always, since we're explicitly supplying the type information. In the case of a base type and a child type, T can be the base type and value can be of the child type in a valid generic call...so these can differ.

Thoughts?

@dude0001
Copy link
Copy Markdown

@NickCraver & @mgravell Are there any plans to pull this in soon?

@ghost1face
Copy link
Copy Markdown

Hey all, I just ran across this PR which looks to resolve an issue I've just run into:

DateTime? dateParam = default;
var params = new {  dateParam = dateParam };

var result = connection.ExecuteScalar<object>("SELECT 1 FROM table WHERE date = @dateParam", params);

I'm using a Postgres database, and receive an exception: could not determine data type of parameter $1.

Of course this is a silly example, but it gets the point across. Are there any plans for this PR to make it into the code base soon?

@NickCraver NickCraver changed the base branch from master to main June 20, 2020 13:25
@Patman0021
Copy link
Copy Markdown

@NickCraver @mgravell
ping?

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.

5 participants