Skip to content
This repository was archived by the owner on Dec 29, 2020. It is now read-only.
This repository was archived by the owner on Dec 29, 2020. It is now read-only.

TypeConverter ignored when creating SqlArgument #415

@Chimaine

Description

@Chimaine

According to the wiki page on Type Converters, registering a converter via

TypeConverter.Converters.Add(new MyTypeConverter());

should be enough for converting to and from database values for a specific type. With session.Insert() it works as expected.

However, when using custom queries with arguments, only DbType mappings are considered.
I'm currently using a little helper to do the conversion for me.

public static SqlArgument GetArgument( object value )
{
    var type = value.GetType();
    var converter = TypeConverter.For( type );
    var result = converter.ConvertToDbValue( value, type );
    return new SqlArgument( result );
}

This works fine, however this might be a more common problem then just for me, so something like this could be supported by ML itself.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions