Skip to content

Conversation

@renanmt
Copy link

@renanmt renanmt commented Oct 31, 2016

Hello guys.

I changed a bit the implementation of the Get method so it can also work with composite keys. I have a few tables with this design and it always annoyed me the fact that Update, Insert and Delete supported them but I had to write custom queries when I wanted to retrieve records from database.

The method still works the same way it was defined before.

var regularKey = connection.Get<RegularKey>(1);

But now also supports operations like this:

var keytest11 = connection.Get<KeyTest>(new KeyTest { Id1 = 1, Id2 = 2 });
var keytest12 = connection.Get<KeyTest>(new { id1 = 1, id2 = 2 });
var keytest21 = connection.Get<KeyTest>(new { Id1 = 2, Id2 = 1 });

var singleKey1 = connection.Get<SingleKey>(1);
var singleKey2 = connection.Get<SingleKey>(new { myKey = 2 });

I was also able to optimize Update and Delete methods a bit by using a new method to retrieve all keys.

For your appreciation and code review.

Cheers

@NickCraver NickCraver added the v3.0 Changes awaiting the next breaking release label Jan 28, 2017
@NickCraver NickCraver modified the milestone: v2.0 Jan 30, 2017
@Adondriel
Copy link

.< Wish this one would have been merged in, I need composite keys in my .net core application.

@cremor
Copy link
Contributor

cremor commented Jul 4, 2017

Related: #812 (also for the new GenerateGetParams method)

@andreaLeo
Copy link

nice ! will it be available soon ?? hope so !

@renanmt
Copy link
Author

renanmt commented Mar 30, 2018

It's been a year and half since I proposed this quite simple change to allow multiple keys on Get method.
All other methods (Insert, Update, Delete) already support multiple keys.

Hi @NickCraver
Do you want me to redo this in the current state of the branch so we can just see it merged soon?
Cause waiting for v2 seems to be not quite realistic anymore.

Cheers

@SwissMaWi
Copy link

I am sad this never came true... @renanmt are you still somehow on this or did you give up yet?

@renanmt
Copy link
Author

renanmt commented Feb 13, 2019

I am sad this never came true... @renanmt are you still somehow on this or did you give up yet?

Hi @SwissMaWi , I'm suffering from serious lack of time to look into this. I will try my best to get back to it next month, meanwhile, I'm attaching my current working versions. You don't need to install Contrib if you just place this files in your application, since they are basically static helpers.

Dapper.Contrib.zip

@renanmt
Copy link
Author

renanmt commented Jan 28, 2021

I will try to fix. It's been almost 5 years and still not supported in Contrib.
Hold my beer. 🍺

@renanmt
Copy link
Author

renanmt commented Feb 1, 2021

Because of the really old PR done in a branch that doesn't even exist anymore I found it a lot easier if I tried to re-implement it in a new branch from "main".

Here's the link to the new PR #1614.

This one can be defined as DEPRECATED.

@renanmt renanmt closed this Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v3.0 Changes awaiting the next breaking release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants