Skip to content

With duplicate fields in resultset, dapper doesn't throw an exception #1322

@garethrepton

Description

@garethrepton

If you have a query where two fields have the same name in a resultset, and in your dapper call you explicitly map to an object... something like:

Connection.Query<MyObjectWithIdField>("Select Id, 1 as Id from MyTable");

Dapper seems to be mapping the last instance of Id it finds in the row to the objects field. In this circumstance it seems like it should be throwing an exception as theres no way of knowing which of the Id fields are the intended result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions