Skip to content

Bug: IPropertyHandler not being called #514

@bcssov

Description

@bcssov

I'm referencing this issue #437 and, yes, I'm aware of the pitfalls of doing string to Guid conversion. DB design is not under my control so I can only consume it.

First of all I've switched to MDS in the sample and have discovered another unrelated issue as reported here #513.

Now the default sample works but in a scenario where you use map attribute the property handler is not being called. As I mentioned the db design is not under my control I am merely a consumer (third party). So consider the following example.

  • Create the following table:
connection.ExecuteNonQuery(@"CREATE TABLE IF NOT EXISTS demoUpsertObj
	(
		id char(36) PRIMARY KEY,
		entityId INTEGER,
		name TEXT NOT NULL,
		validFrom Datetime,
		validTo  datetime,
		deleted byte
	);");
  • Decorate the model as follows:
    [Map("demoUpsertObj")]
    public class DemoUpsertObj //: IUpsertEntity
    {
        [Map("id"), Primary, PropertyHandler(typeof(StringToGuidPropertyHandler))]
        public Guid Id { get; set; }
        [Map("entityId")]
        public long EntityId { get; set; }
        [Map("validFrom")]
        public DateTime ValidFrom { get; set; }
        [Map("validTo")]
        public DateTime ValidTo { get; set; }
        [Map("deleted")]
        public byte Deleted { get; set; }
        [Map("name")]
        public string Name { get; set; }
        public DemoUpsertObj() { }
        public DemoUpsertObj(string name)
        {
            Name = name;
        }
    }
  • Perform the query:
    var result = connection.Query<DemoUpsertObj>(p => p.Id == recordId).FirstOrDefault();

No results will be returned. Remove the map attribute or just lowercase the property and a match will be returned.

Modified sample project:
RepoDbIssue437.zip

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdeployedFeature or bug is deployed at the current releasefixedThe bug, issue, incident has been fixed.todoThings to be done in the future

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions