Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underscored names don't work with MatchNamesWithUnderscores = true #297

Closed
b2soft opened this issue Aug 11, 2023 · 3 comments
Closed

Underscored names don't work with MatchNamesWithUnderscores = true #297

b2soft opened this issue Aug 11, 2023 · 3 comments

Comments

@b2soft
Copy link

b2soft commented Aug 11, 2023

Hello. I have a table auth with fields id and discord_id. I have such a model:

[Table("auth")]
public class AuthDataModel
{
    [Key, Identity]
    public int Id { get; set; }
    public string DiscordId { get; set; }
}

Dapper is configured to ignore underscores: Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;

Now when I try to get all the records using var foundUsers = (await m_authRepository.FindAllAsync()).ToList(); I get an error: 42703: column auth.discordid does not exist
While this call works correctly:
await m_authRepository.Connection.QueryAsync<AuthDataModel>("SELECT * FROM auth")).ToList();
May be related to DapperLib/Dapper#818

What is the possible solution other than marking all the underscore named columns with [Column("underscored_name")] ?

Thanks

@phnx47
Copy link
Owner

phnx47 commented Aug 12, 2023

@b2soft SqlGenerator doesn't read Dapper.DefaultTypeMap.MatchNamesWithUnderscores. Current solution only with [Column("underscored_name")]

@b2soft
Copy link
Author

b2soft commented Aug 12, 2023

Are there any plans to support such flag?

@phnx47
Copy link
Owner

phnx47 commented Aug 13, 2023

@b2soft Flag about mapping, not about sql generation...
I guess you want support naming conventions in SqlGenerator. If you have time feel free to implement it and raise a PR.

@phnx47 phnx47 added the wontfix label Aug 16, 2023
@phnx47 phnx47 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2023
@phnx47 phnx47 added enhancement and removed wontfix labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants