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

ColumnAttribute is not mapping columns to strong type property. #457

Closed
lesair opened this issue Mar 17, 2021 · 2 comments
Closed

ColumnAttribute is not mapping columns to strong type property. #457

lesair opened this issue Mar 17, 2021 · 2 comments

Comments

@lesair
Copy link

lesair commented Mar 17, 2021

I have my POCO strong type defined like this:

public class Fruit
{
  [Key("Fruit_Id")] [Ignore] public string FruitId { get; set; }
  [Column("Full_Name")] public string FullName { get; set; }
}

But the column names mappings are not working when fetching rows:
IEnumerable<Fruit> fruits = db.Query("Fruit").Get<Fruit>();

I get the rows but the class properties whose names differ from the table columns are not filled, if I rename my class properties names then the mapping is done correctly, so apparently the ColumnAttribute I am using is useless.

Regards.

@zerofairnight
Copy link

This library uses Dapper under the hood, and Dapper does not support attribute mapping.

For your specific use case, try with:

Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;

The column attribute you referring is used for inserting and updating only.

@lesair
Copy link
Author

lesair commented Mar 22, 2021

Thank you @zerofairnight

@lesair lesair closed this as completed Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants