Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot insert boolean using oracle #877

Copy link
Copy link

Description

@DVoavi-Arison
Issue body actions

sqlQuery variable

insert into SomeTable (
  SomeBoolValue // number(1, 0)
) values (
  :SomeBoolValue
);

Dapper call

Class SomeTable {
  bool SomeBoolValue
}
...
var values = new SomeTable{SomeBoolValue = false};
this.conn.ExecuteAsync(sqlQuery, values );

That is causing an exception.

I tried to create a BoolTypeHandler but it was not even called by dapper

         {
               ...
               SqlMapper.AddTypeHandlerImpl(typeof(bool), new BoolTypeHandler(), true);
              ...
         }

        public class BoolTypeHandler : SqlMapper.TypeHandler<bool>
        {
            public override void SetValue(IDbDataParameter parameter, bool value)
            {
                parameter.Value = value ? (byte)1 : (byte)0;
            }

            public override bool Parse(object value)
            {
                return bool.Parse((string)value); // This is just an example
            }
        }
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.