Skip to content

Question: ColumnName Resolver #387

@andreas-soroko

Description

@andreas-soroko

Hey,

in #366 i already asked if it would be possible to add a columName resolver and you gave me same examples... but i dont get it.

so first, some code:

[Map("enum_test_table")]
private class TestModel
{
    [Primary]
    public Guid Id { get; set; }
    public JObject JsonData { get; set; }
}
create table enum_test_table(id uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(), json_data jsonb);

now i thought, i need to replace this boy PostgreSqlConvertFieldResolver

and the only way i found to pass the resolver is

StatementBuilderMapper.Add(typeof(NpgsqlConnection), GetStatementBuilder(), true);

IStatementBuilder GetStatementBuilder()
{
    return new PostgreSqlStatementBuilder(
        DbSettingMapper.Get(typeof(NpgsqlConnection)),
        new PostgresFieldResolver(), // my resolver, just 1:1 copy from yours currently, but debug points does not stop there
        new ClientTypeToAverageableClientTypeResolver());
}
var model = new TestModel()
{
    Id = Guid.NewGuid(),
    JsonData = JObject.FromObject(new
    {
        testField = "data"
    })
};
await repo.InsertAsync<Guid>(model);

error -> Npgsql.PostgresException : 42703: column "Id" of relation "enum_test_table" does not exist

what is my goal ?

  • use on all props snake_case without using MapAttribute
  • If MapAttribute is defined, then it wins over the fieldResolver

thank you for your help!

Metadata

Metadata

Assignees

Labels

deployedFeature or bug is deployed at the current releaserequestA request from the community.todoThings to be done in the future

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions