Skip to content

Conversation

@renanmt
Copy link

@renanmt renanmt commented Feb 1, 2021

THIS IS A NEW VERSION OF A VERY OLD AND FORGOTTEN PULL REQUEST ( #636).
PLEASE REVIEW IT WITH LOVE. 🥰

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

@renanmt
Copy link
Author

renanmt commented Feb 1, 2021

image

Some weird behavior on:

`private static ISqlAdapter GetFormatter(IDbConnection connection)
{
var name = GetDatabaseType?.Invoke(connection).ToLower()
?? connection.GetType().Name.ToLower();

return AdapterDictionary.TryGetValue(name, out var adapter)
    ? adapter
    : DefaultAdapter;

}`

Apparently it is returning the default adapter (SQLServer) in the build machine.

@cremor
Copy link
Contributor

cremor commented Feb 2, 2021

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

@Simon-Carr
Copy link

I have a similar build issue on my contrib PR (#1586).

@NickCraver
Copy link
Member

I can't speak to Contrib's future plans here and if this is a good fit, but please see #1658 - Dapper.Contrib is not located at https://github.com/DapperLib/Dapper.Contrib (separate from this repository).

Note: I based the Dapper.Contrib fork on the original codebase which hopefully makes porting pull requests against the main branch there much easier - the intent was to split, not throw away work the community wants to go with.

@NickCraver NickCraver closed this May 9, 2021
@NickCraver NickCraver added the area:contrib Dapper.Contrib related label May 9, 2021
@renanmt
Copy link
Author

renanmt commented May 9, 2021

Hi @NickCraver. Thanks for letting us know.
Because the PR was never accepted, I basically rebuilt all Contrib functionalities from scratch in a new Library.
I'm moving all my dependencies from Contrib to this new one at work (Ubisoft). Maybe pass by and check it out if it interests
you: https://github.com/renanmt/Dapper.Apex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:contrib Dapper.Contrib related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants