DapperLib / Dapper.Contrib

Dapper community contributions - additional extensions for Dapper
Other
267 stars 99 forks source link

SqlMapperExtensions.Get doesn't work on netcore2.2 in Linux platform #1

Open ProgrammerLiZhiYue opened 3 years ago

ProgrammerLiZhiYue commented 3 years ago

I have a project which run perfect in net core 2.2 in Windows platform, but since i switch to Linux platform (Ubuntu 20.04), I get a suddent error with "Get only supports an entity with a [Key] or an [ExplicitKey] property". Then I found https://github.com/StackExchange/Dapper/blob/6ec3804f2c44f2bf6b757dc3522bf009cc64b27d/Dapper.Contrib/SqlMapperExtensions.cs#L112, This code try to find some property which name is Id (case ignore), but since StringComparison.CurrentCultureIgnoreCase has some issue in netcore 2.2 in Mac/Linux, so this code return idProp with null caused the error. I think use this var idProp = allProperties.Find(p => string.Equals(p.Name.ToLower(), "id")); may be better.

NickCraver commented 3 years ago

Changing to be case insensitive would be a breaking change, so we'll need to find another route here. Are you seeing this in later .NET Core releases?