Skip to content

How to map a complex parameter type to the underlying db type? #535

@jfrank14

Description

@jfrank14

I'm using InsightDB to call stored procs, and this has been working for me beautifully for many years.

Now I'm trying to add some strong type safety to my code base so that instead of having properties like int LoginId {get; set;} on my models, I use a (code generated) custom strong type to make it LoginId LoginId {get; set;}

So I have a model like

class Beer
{
   LoginId LoginId {get; set;}
   string Something {get; set;}
   ...
}

and I want to pass this to a call like ExecuteAsync and it fails with Failed to convert parameter value from a LoginId to a Int32.

This is not surprising to me, since how could it know what I mean here?

But I cannot find a way to configure this so that it works. What I want is a way to tell InsightDB that whenever you see a property of type LoginId, reach into it and use LoginId.Value instead. But I cannot find any configuration that lets me do this. The closest I've come is a custom IParameterMapper, but this isn't firing as I would expect; it's only called on the first proc I call, and then never again.

EntityFramework has the concept of a value converter, but I can't find anything like that in InsightDB.

How to proceed?!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions