TortugaResearch / Tortuga.Chain

A fluent ORM for .NET
Other
335 stars 22 forks source link

Tortuga.Chain.MappingException: 'Cannot map value of type System.String to property Gender of type Char.' #469

Closed agrinei closed 2 years ago

agrinei commented 2 years ago

Microsoft SQL Server 2019 Tortuga.Chain.SqlServer.MDS 4.1.0 (just released)

We have an AppUsers table which has a Gender column - char(1) not nullable. When trying to map the Gender column to the CLR char datatype we get the exception above.

Sample:

create table AppUsers ( Id int not null, [Name] nvarchar(100) not null, Gender char(1) not null )

public class AppUser { public int Id { get; set; } public string Name { get; set; } public char Gender { get; set; } }

Sql("select Name, Gender from AppUsers where Id = @id", new { id = 1 }).ToObjectOrNull().Execute();

Grauenwolf commented 2 years ago

Interesting. I don't know that we support Char as a property type. But if that's the case, the fix should be easy.

I should have time to work on it today.

agrinei commented 2 years ago

That's awesome! :D

Grauenwolf commented 2 years ago

I think I found all the places where the change needs to be made. Running the tests now.

Grauenwolf commented 2 years ago

Ok, it will be part of the 4.2 release.

Grauenwolf commented 2 years ago

Ok, I think I've chased down all of the possible Char scenarios.

@agrinei feel free to reach out if you think I've missing anything.

Grauenwolf commented 2 years ago

Ugh, forgot ToCharSet. Adding #475 to the list.

Grauenwolf commented 2 years ago

v4.2 ha been published. https://github.com/TortugaResearch/Tortuga.Chain/releases/tag/v4.2.0

agrinei commented 2 years ago

Everything working great. Thanks! Is there a way to support this project?

Grauenwolf commented 2 years ago

Honestly, the best way to support a project like this is to help with feature design and testing.

Progress requires motivation. And motivation comes from working with people who are using the library to solve their problems.

Grauenwolf commented 2 years ago

For example, four of the last seven features arose from this bug fix and things that naturally followed from it.

agrinei commented 2 years ago

That's great. I'm using the project for a long time and I see it as very mature and consistent. Anyway, if I find some room for improvement I'll be happy to share. Thank you again.

Grauenwolf commented 2 years ago

You're welcome.