Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Duplicate Columns mapping with same name... can you give a look :)

Open softwarekamal opened this issue 4 years ago • 4 comments

Hello Marc, hope you are fine my dear:) Can you look at this thread please. https://stackoverflow.com/questions/66096906/how-to-return-unique-columns-only-with-join-statement-in-dapper-query-sql

Looks like the columns returned from dapper join query. are duplicated. Maybe you can implement something that mapping duplicate columns as Column1, Column2, Column3 Because with some of bindable grid / treelists. it throw exception. It need to focus to single column only.

softwarekamal avatar Feb 08 '21 06:02 softwarekamal

Maybe something like Query("SELECT * FROM Table", uniqueColumns : true) I searched for such thing but no results :(

softwarekamal avatar Feb 08 '21 06:02 softwarekamal

I think the best solution here is to not use SELECT *, why can't you list your columns here?

rhubley avatar Feb 08 '21 15:02 rhubley

I described that my dear Maybe something like Query("SELECT * FROM Table", uniqueColumns : true) DataTable rename duplicate columns to columnID1, columnID2, etc. Its better Dapper maybe support that or allow only unique columns. SELECT * Is bad practice but. In my table I must select all columns (35+) using them in the form / report. etc.

softwarekamal avatar Feb 08 '21 17:02 softwarekamal

@softwarekamal you can achieve the desired behavior by using manual mapping with the help of SqlDataReader. Here's the sample code

aciudacov avatar Nov 07 '24 19:11 aciudacov